# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
100672 |
2019-03-13T06:48:37 Z |
Pro_ktmr |
None (JOI16_memory2) |
C++14 |
|
3 ms |
512 KB |
#include<bits/stdc++.h>
#include"Memory2_lib.h"
using namespace std;
#define LL long long
#define MP(a,b) make_pair(a,b)
/*
int Flip(int I, int J){
cout << I << " " << J << endl;
int tmp;
cin >> tmp;
return tmp;
}
void Answer(int I, int J, int X){
cout << I << " " << J << " " << X << endl;
}*/
//all 0-indexed
//Flip(int I, int J)
//Answer(int I, int J, int X)
void Solve(int T, int N){
N *= 2;
int ans[100];
vector<int> yet[2];
for(int i=0; i<N; i++) yet[1].push_back(i);
random_device seed;
mt19937 engine(seed());
while(yet[1].size() > 3){
yet[0].clear();
yet[0] = yet[1];
yet[1].clear();
shuffle(yet[0].begin(), yet[0].end(), engine);
vector<int> tmp;
for(int i=0; i<yet[0].size(); i++){
tmp.push_back(yet[0][i]);
if(tmp.size() == 4){
//cout << tmp[0] << " " << tmp[1] << " " << tmp[2] << " " << tmp[3] << endl;
vector<int> f[4];
int x = Flip(tmp[0],tmp[1]);
f[0].push_back(x);
f[1].push_back(x);
x = Flip(tmp[0],tmp[2]);
f[0].push_back(x);
f[2].push_back(x);
x = Flip(tmp[0],tmp[3]);
f[0].push_back(x);
f[3].push_back(x);
x = Flip(tmp[1],tmp[2]);
f[1].push_back(x);
f[2].push_back(x);
x = Flip(tmp[1],tmp[3]);
f[1].push_back(x);
f[3].push_back(x);
x = Flip(tmp[2],tmp[3]);
f[2].push_back(x);
f[3].push_back(x);
sort(f[0].begin(), f[0].end());
sort(f[1].begin(), f[1].end());
sort(f[2].begin(), f[2].end());
sort(f[3].begin(), f[3].end());
bool already[4] = {};
int c = 0;
int d = 0;
for(int j=0; j<4; j++){
if(f[j][0] == f[j][1] && f[j][1] == f[j][2]){
ans[tmp[j]] = f[j][0];
already[j] = true;
c++;
}
else if(f[j][0] == f[j][1] || f[j][1] == f[j][2] || f[j][2] == f[j][0]){
d++;
}
}
if(c == 1 && d == 1){
for(int j=0; j<4; j++){
if(f[j][0] == f[j][1] && f[j][1] == f[j][2]){
}
else if(f[j][0] == f[j][1] || f[j][1] == f[j][2]){
ans[tmp[j]] = f[j][1];
already[j] = true;
}
else if(f[j][2] == f[j][0]){
ans[tmp[j]] = f[j][2];
already[j] = true;
}
}
}
for(int j=0; j<4; j++){
if(!already[j]) yet[1].push_back(tmp[j]);
}
//cout << already[0] << " " << already[1] << " " << already[2] << " " << already[3] << endl;
tmp.clear();
}
}
for(int i=0; i<tmp.size(); i++){
yet[1].push_back(tmp[i]);
}
}
yet[0].clear();
yet[0] = yet[1];
yet[1].clear();
sort(yet[0].begin(), yet[0].end());
if(yet[0].size() == 3){
vector<int> f[3];
int x = Flip(yet[0][0],yet[0][1]);
f[0].push_back(x);
f[1].push_back(x);
x = Flip(yet[0][0],yet[0][2]);
f[0].push_back(x);
f[2].push_back(x);
x = Flip(yet[0][1],yet[0][2]);
f[1].push_back(x);
f[2].push_back(x);
sort(f[0].begin(), f[0].end());
sort(f[1].begin(), f[1].end());
sort(f[2].begin(), f[2].end());
for(int j=0; j<3; j++){
if(f[j][0] == f[j][1]){
ans[yet[0][j]] = f[j][0];
yet[0].erase(yet[0].begin()+j);
break;
}
}
}
for(int i=0; i<N/2; i++){
vector<int> tmp;
for(int j=0; j<N; j++){
if(yet[0][0] != j && yet[0][1] != j && ans[j] == i) tmp.push_back(j);
}
if(tmp.size() == 2) Answer(tmp[0], tmp[1], i);
else Answer(yet[0][0], yet[0][1], i);
}
}
/*
int main(){
Solve(0,3);
return 0;
}*/
Compilation message
memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:36:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<yet[0].size(); i++){
~^~~~~~~~~~~~~~
memory2.cpp:104:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<tmp.size(); i++){
~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
356 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Incorrect |
2 ms |
512 KB |
Wrong Answer[2] |
5 |
Halted |
0 ms |
0 KB |
- |