Created
August 1, 2023 10:15
-
-
Save lrw04/6e11e6780a6522111dbb50439f0039d1 to your computer and use it in GitHub Desktop.
Set sorted output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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