#include "Memory2_lib.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <map>
using namespace std;
int ans[100];
int cnt[100];
int mem[100][2];
int pos[50][2];
multimap<int, int> m;
void put(int i, int v)
{
ans[i] = v;
if(pos[v][0] == -1)
pos[v][0] = i;
else
pos[v][1] = i;
m.insert({ v, i });
}
void Solve(int T, int N){
memset(ans, -1, sizeof(ans));
memset(pos, -1, sizeof(pos));
bool u;
int r, c, p, x, i, j, k;
for(i = 0; i<2*N; i++)
{
if(ans[i] != -1)
continue;
u = 1;
p = 0;
memset(cnt, 0, sizeof(cnt));
for(j = 0; j<2*N; j++)
{
if(ans[j] != -1 || i == j)
continue;
r = Flip(i, j);
cnt[r]++;
if(cnt[r] == 3)
{
u = 0;
c = r;
break;
}
mem[p][0] = j;
mem[p++][1] = r;
}
if(u)
{
auto it = m.end();
for(j = 0; j<3 && it != m.begin(); j++)
{
it--;
r = Flip(i, it->second);
cnt[r]++;
if(cnt[r] == 3)
{
u = 0;
break;
}
}
}
if(!u)
{
for(k = 0; k<p; k++)
if(mem[k][1] != c)
put(mem[k][0], mem[k][1]);
put(i, c);
continue;
}
x = i;
for(k = 0; k<p; k++)
put(mem[k][0], mem[k][1]);
break;
}
for(i = 0; i<N; i++)
{
if(pos[i][1] == -1)
pos[i][1] = x;
Answer(pos[i][0], pos[i][1], i);
}
return;
}
Compilation message
memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:100:26: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
pos[i][1] = x;
^
memory2.cpp:87:22: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
put(i, c);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1180 KB |
Output is correct |
2 |
Correct |
0 ms |
1180 KB |
Output is correct |
3 |
Correct |
0 ms |
1180 KB |
Output is correct |
4 |
Correct |
0 ms |
1180 KB |
Output is correct |
5 |
Correct |
0 ms |
1180 KB |
Output is correct |
6 |
Correct |
0 ms |
1180 KB |
Output is correct |
7 |
Correct |
0 ms |
1180 KB |
Output is correct |
8 |
Correct |
0 ms |
1180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1180 KB |
Output is correct |
2 |
Correct |
0 ms |
1180 KB |
Output is correct |
3 |
Correct |
0 ms |
1180 KB |
Output is correct |
4 |
Correct |
0 ms |
1180 KB |
Output is correct |
5 |
Correct |
0 ms |
1180 KB |
Output is correct |
6 |
Correct |
0 ms |
1180 KB |
Output is correct |
7 |
Correct |
0 ms |
1180 KB |
Output is correct |
8 |
Correct |
0 ms |
1180 KB |
Output is correct |
9 |
Correct |
0 ms |
1180 KB |
Output is correct |
10 |
Correct |
0 ms |
1180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1180 KB |
Wrong Answer[3] |
2 |
Halted |
0 ms |
0 KB |
- |