# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
708182 |
2023-03-11T09:03:26 Z |
device |
None (JOI16_memory2) |
C++17 |
|
1 ms |
308 KB |
#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y){
return uniform_int_distribution<int>(x, y)(rng);
}
int Flip(int I, int J);
void Answer(int I, int J, int X);
void out(int i, int j, int k) {
if (i > j) swap(i, j);
Answer(i, j, k);
}
void Solve(int t, int n){
vector<int> v;
for (int i = 0; i < (n << 1); i++) v.push_back(i);
while (!v.empty()) {
vector<vector<int>> p(n);
int ptr = v[rnd(0, v.size()-1)], itt;
for (int i = 0; i < v.size(); i++) if (v[i] != ptr) p[Flip(ptr, v[i])].push_back(v[i]);
for (int i = 0; i < n; i++) {
if (p[i].size() == 2) {
v.erase(find(v.begin(), v.end(), p[i][0]));
v.erase(find(v.begin(), v.end(), p[i][1]));
out(p[i][0], p[i][1], i);
} else if (p[i].size() & 1) itt = i;
}
if (v.size() == 2) {
out(v[0], v[1], itt);
return;
}
}
}
Compilation message
memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:19:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for (int i = 0; i < v.size(); i++) if (v[i] != ptr) p[Flip(ptr, v[i])].push_back(v[i]);
| ~~^~~~~~~~~~
memory2.cpp:11:11: warning: 'itt' may be used uninitialized in this function [-Wmaybe-uninitialized]
11 | Answer(i, j, k);
| ~~~~~~^~~~~~~~~
memory2.cpp:18:42: note: 'itt' was declared here
18 | int ptr = v[rnd(0, v.size()-1)], itt;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
308 KB |
Output is correct |