Skip to content

Instantly share code, notes, and snippets.

@lrw04
Created August 1, 2023 10:15
Show Gist options
  • Save lrw04/6e11e6780a6522111dbb50439f0039d1 to your computer and use it in GitHub Desktop.
Save lrw04/6e11e6780a6522111dbb50439f0039d1 to your computer and use it in GitHub Desktop.
Set sorted output
import random
n = 20000000
v = 100000000
l = list(range(v))
random.shuffle(l)
l = l[:n]
with open('input.txt', 'w') as f:
print('\n'.join((str(x) for x in l)), file=f)
with open('answer.txt', 'w') as f:
print('\n'.join((str(x) for x in sorted(l))), file=f)
#include <bitset>
#include <fstream>
const int N = 1e8;
std::bitset<N> s;
int main() {
std::ifstream input("input.txt");
std::ofstream output("output.txt");
int x;
while (input >> x) s.set(x);
for (int i = 0; i < N; i++)
if (s[i]) output << i << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment