#include "Memory2_lib.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = 128;
int G[N][N];
int get(int x,int y) {
if (x > y)
swap(x,y);
if (G[x][y] == -1)
G[x][y] = Flip(x,y);
return G[x][y];
}
int ans[N];
vi pos[N];
void Solve(int T, int NN) {
int n = NN;
memset(G,-1,sizeof(G));
set < int > st;
for (int i = 0;i < n + n;++i)
st.insert(i),ans[i] = -1;
while (st.size() >= 4) {
vi II(all(st));
set < int > nxt;
for (int i = 0;i + 4 <= II.size();++i) {
int a = II[i];
int b = II[i + 1];
int c = II[i + 2];
int d = II[i + 3];
vi p = {a,b,c,d};
for (int cs = 0;cs < 2;++cs) {
int sz = p.size();
int who = -1;
for (int i = 0;i < sz;++i) {
vi v;
for (int j = 0;j < sz;++j)
if (i != j)
v.pb(get(p[i],p[j]));
sort(all(v));
if (v[0] == v.back()) {
who = i;
break;
}
}
assert(who != -1);
if (!who)
ans[p[who]] = get(p[1],p[who]);
else
ans[p[who]] = get(p[0],p[who]);
p.erase(p.begin() + who);
}
for (auto it : p)
nxt.insert(it);
}
while (st.size() > 4 && nxt.size() < 4) {
for (auto it : st)
if (!nxt.count(it)) {
nxt.insert(it);
break;
}
}
st = nxt;
}
for (int i = 0;i < n + n;++i) {
if (ans[i] == -1)
ans[i] = n - 1;
pos[ans[i]].pb(i);
}
for (int i = 0;i < n;++i)
Answer(pos[i][0],pos[i][1],i);
}
Compilation message
memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:46:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0;i + 4 <= II.size();++i) {
~~~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Wrong Answer[3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
488 KB |
Wrong Answer[2] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
588 KB |
Wrong Answer[2] |
2 |
Halted |
0 ms |
0 KB |
- |