QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#117240 | #6668. Trokuti | kshitij_sodani | 0 | 0ms | 0kb | C++14 | 3.2kb | 2023-06-30 19:13:10 | 2023-06-30 19:13:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
typedef long long llo;
//#define endl '\n'
int ans[101][101];
int vis[101][101][101];
int val[101][101];
int su=0;
int query(int aa,int bb,int cc){
int x=min(aa,min(bb,cc));
int y=max(aa,max(bb,cc));
int z=aa;
if(z==x or z==y){
z=bb;
}
if(z==x or z==y){
z=cc;
}
if(vis[x][z][y]>=0){
return vis[x][z][y];
}
cout<<"? "<<x+1<<" "<<z+1<<" "<<y+1<<endl;
int xx;
xx=val[x][y]+val[y][z]+val[z][x];;
cin>>xx;
su++;
vis[x][z][y]=xx;
return xx;
}
void set2(int i,int j,int k){
ans[i][j]=k;
ans[j][i]=k;
}
mt19937 rng;
vector<int> cur;
void solve(int i,vector<int> tt){
shuffle(tt.begin(),tt.end(),rng);
vector<pair<int,int>> ee;
for(int j=0;j<tt.size();j+=2){
if(j+1==tt.size()){
set2(i,tt[j],query(cur[0],i,tt[j])-ans[cur[0]][i]-ans[cur[0]][tt[j]]);
}
else{
int x=query(i,tt[j],tt[j+1])-ans[tt[j]][tt[j+1]];
if(x==0){
set2(i,tt[j],0);
set2(i,tt[j+1],0);
}
else if(x==2){
set2(i,tt[j],1);
set2(i,tt[j+1],1);
}
else{
ee.pb({tt[j],tt[j+1]});
}
}
}
if(ee.size()){
vector<int> ff;
for(auto j:ee){
ff.pb(j.a);
}
solve(i,ff);
for(int j=0;j<ee.size();j++){
set2(i,ee[j].b,1-ans[i][ee[j].a]);
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n=100;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
for(int k=0;k<n;k++){
vis[i][j][k]=-1;
}
}
}
rng=mt19937(chrono::steady_clock::now().time_since_epoch().count());
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
val[i][j]=rng()%2;
val[j][i]=val[i][j];
}
}
for(int i=0;i<6;i++){
for(int j=i+1;j<6;j++){
for(int k=j+1;k<6;k++){
query(i,j,k);
//cout<<vis[i][j][k]<<":"<<endl;
if(vis[i][j][k]==0 or vis[i][j][k]==3 and cur.size()==0){
cur.pb(i);
cur.pb(j);
cur.pb(k);
int z=1;
if(vis[i][j][k]==0){
z=0;
}
set2(i,j,z);
set2(i,k,z);
set2(j,k,z);
}
}
}
}
shuffle(cur.begin(),cur.end(),rng);
/*cout<<11<<endl;
for(auto j:cur){
cout<<j<<",";
}
cout<<endl;
return 0;*/
vector<int> tt;
for(int i=0;i<n;i++){
if(i==cur[0] or i==cur[1] or i==cur[2]){
continue;
}
// shuffle(cur.begin(),cur.end(),rng);
int aa=query(i,cur[0],cur[1])-ans[cur[0]][cur[1]];
int bb=query(i,cur[1],cur[2])-ans[cur[1]][cur[2]];
if(aa==0 or aa==2){
set2(i,cur[0],aa/2);
set2(i,cur[1],aa/2);
set2(i,cur[2],bb-(aa/2));
continue;
}
else if(bb==0 or bb==2){
set2(i,cur[1],bb/2);
set2(i,cur[2],bb/2);
set2(i,cur[0],aa-(bb/2));
continue;
}
int cc=query(i,cur[2],cur[0])-ans[cur[2]][cur[0]];
int su=(aa+bb+cc)/2;
set2(i,cur[2],su-aa);
set2(i,cur[0],su-bb);
set2(i,cur[1],su-cc);
}
for(int i=0;i<n;i++){
if(i==cur[0] or i==cur[1] or i==cur[2]){
continue;
}
solve(i,tt);
tt.pb(i);
}
cout<<"!"<<endl;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
assert(ans[i][j]==val[i][j]);
cout<<ans[i][j];
}
cout<<endl;
}
// cout<<su<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Dangerous Syscalls
Test #1:
score: 0
Dangerous Syscalls
input:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
? 1 2 3 ? 1 2 4 ? 1 2 5 ? 1 2 6 ? 1 3 4 ? 1 3 5 ? 1 3 6 ? 1 4 5 ? 1 4 6 ? 1 5 6 ? 2 3 4 ? 2 3 5 ? 2 3 6 ? 2 4 5 ? 2 4 6 ? 2 5 6 ? 3 4 5 ? 3 4 6 ? 3 5 6 ? 4 5 6 ? 1 1 2 ? 1 1 4 ? 1 1 5 ? 1 1 6 ? 1 1 7 ? 1 3 7 ? 1 1 8 ? 1 3 8 ? 1 1 9 ? 1 3 9 ? 1 1 10 ? 1 3 10 ? 1 1 11 ? 1 3 11 ? 1 1 12 ? 1 3 12 ? 1 1 ...