#include "Memory2_lib.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cassert>
#include <random>
#include <map>
#include <ctime>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
#define index(x, y) (int)(lower_bound(all(x), y) - x.begin())
#define pb push_back
#define _1 first
#define _2 second
#define INF 1145141919
#define MOD 1000000007
int get_min_pos(vector<int> pos, int N) {
rep(i, pos.size()) rep(j, i) {
if (Flip(pos[i], pos[j]) == N-1) return pos[i];
}
return -1;
}
mt19937 mt_rand(time(NULL));
vector<int> G[50];
int A[100];
int V[100];
void Solve(int T, int N) {
rep(i, 2*N) A[i] = -1;
if (T == 3) abort();
vector<int> pos;
rep(i, 2*N) pos.pb(i);
while (pos.size() > 2) {
int p = pos[mt_rand()%pos.size()];
int mx = -1;
map<int, int> cnt;
for (int x : pos) if (x != p) {
int v = Flip(x, p);
V[x] = v;
mx = max(mx, v);
cnt[v]++;
}
vector<int> npos;
npos.pb(p);
for (int x : pos) if (x != p) {
if (V[x] < mx) A[x] = V[x];
else npos.pb(x);
}
swap(npos, pos);
}
int min_pos = get_min_pos(pos, N);
assert(min_pos != -1);
for (int i : pos) {
int a = N-1;
if (i != min_pos) a = Flip(i, min_pos);
A[i] = a;
}
rep(i, 2*N) G[A[i]].pb(i);
rep(i, N) assert(G[i].size() == 2);
rep(i, N) Answer(G[i][0], G[i][1], i);
}
Compilation message
memory2.cpp: In function 'int get_min_pos(std::vector<int>, int)':
memory2.cpp:13:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define rep(i, n) for (int i=0; i<(n); i++)
^
memory2.cpp:24:3: note: in expansion of macro 'rep'
rep(i, pos.size()) rep(j, i) {
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2032 KB |
Output is correct |
2 |
Correct |
0 ms |
2032 KB |
Output is correct |
3 |
Correct |
0 ms |
2032 KB |
Output is correct |
4 |
Correct |
0 ms |
2032 KB |
Output is correct |
5 |
Correct |
0 ms |
2032 KB |
Output is correct |
6 |
Correct |
0 ms |
2032 KB |
Output is correct |
7 |
Correct |
0 ms |
2032 KB |
Output is correct |
8 |
Correct |
0 ms |
2032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2032 KB |
Output is correct |
2 |
Correct |
0 ms |
2032 KB |
Output is correct |
3 |
Correct |
0 ms |
2032 KB |
Output is correct |
4 |
Correct |
0 ms |
2032 KB |
Output is correct |
5 |
Correct |
0 ms |
2032 KB |
Output is correct |
6 |
Correct |
0 ms |
2032 KB |
Output is correct |
7 |
Correct |
0 ms |
2032 KB |
Output is correct |
8 |
Correct |
0 ms |
2032 KB |
Output is correct |
9 |
Correct |
0 ms |
2032 KB |
Output is correct |
10 |
Correct |
0 ms |
2032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
2032 KB |
Execution killed because of forbidden syscall gettid (186) |
2 |
Halted |
0 ms |
0 KB |
- |