QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#117179 | #6668. Trokuti | Irisu | 0 | 85ms | 11232kb | C++17 | 6.2kb | 2023-06-30 16:11:20 | 2023-06-30 16:11:23 |
Judging History
answer
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;++i)
#define per(i,a,b) for(int i=(a),i##end=(b);i>=i##end;--i)
//mt19937 Rnd(19260817);
mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template<typename T>void chkmax(T&x,const T&y){if(x<y)x=y;}
template<typename T>void chkmin(T&x,const T&y){if(y<x)x=y;}
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define mem(x) memset((x),0,sizeof(x))
typedef double db;
typedef long long ll;
typedef vector<int>vi;
typedef pair<int,int>pii;
typedef unsigned u32;
typedef unsigned uint;
typedef unsigned long long u64;
const int n=100;
#ifdef Arraiter
const bool Irisu=1;
#else
const bool Irisu=0;
#endif
bool mp[105][105];int sf[105],fs[105];int use_q=0;
bool ans[105][105];
struct Querys{
int a,b,c,v;
};
vector<Querys>Q;
int ask(int a,int b,int c){
int v;
a=sf[a],b=sf[b],c=sf[c];
if(Irisu){
use_q++;
v=mp[a][b]+mp[b][c]+mp[a][c];
Q.pb({fs[a],fs[b],fs[c],v});
return v;
}
printf("? %d %d %d\n",a,b,c);
fflush(stdout);
scanf("%d",&v);
Q.pb({fs[a],fs[b],fs[c],v});
return v;
}
void answer(){
if(Irisu){
bool asf=1;
rep(i,1,n)rep(j,1,n)asf&=ans[fs[i]][fs[j]]==mp[i][j];
if(asf){
puts("AC");
printf("count : %d\n",use_q);
}else{
puts("WA");
}
return;
}
puts("!");
rep(i,1,n){
rep(j,1,n)putchar(ans[fs[i]][fs[j]]|48);
puts("");
}
}
const int maxn=5000;
const int m=4950;
int tid[105][105];pii dit[maxn];
struct bit{
u64 seq[78];
void reset(){
mem(seq);
}
void set(int pos){
seq[pos>>6]|=1ull<<(pos&63);
}
void flip(int pos){
seq[pos>>6]^=1ull<<(pos&63);
}
bool operator[](int pos)const{
return seq[pos>>6]>>(pos&63)&1;
}
void operator^=(const bit&o){
rep(i,0,77)seq[i]^=o.seq[i];
}
void doit_pre(const bit&o,int pos){
rep(i,0,pos>>6)seq[i]^=o.seq[i];
}
void doit_suf(const bit&o,int pos){
rep(i,pos>>6,77)seq[i]^=o.seq[i];
}
};
//typedef bitset<maxn>bit;
int rk;
bit B[maxn];bool bb[maxn];
bool ins(bit&x){
per(i,m,1)if(x[i]){
if(bb[i]){
// x^=B[i];
x.doit_pre(B[i],i);
continue;
}
rk++;
bb[i]=1;
B[i]=x;
return 1;
}
return 0;
}
void solve(){
rep(i,1,n)sf[i]=i;
shuffle(sf+1,sf+n+1,Rnd);
rep(i,1,n)fs[sf[i]]=i;
if(Irisu){
rep(i,1,n)rep(j,i+1,n)mp[i][j]=mp[j][i]=i==1;
// rep(i,1,n)rep(j,i+1,n)mp[i][j]=mp[j][i]=Rnd()%100>100;
}
{
int c=0;
rep(i,1,n)rep(j,1,i-1)tid[i][j]=tid[j][i]=++c,dit[c]={i,j};
}
static int buk[maxn];
memset(buk,-1,sizeof buk);
bit w;
auto upd=[&](int i,int v){
if(buk[i]==-1){
buk[i]=v;
w.reset(),w.set(i),ins(w);
}
};
int eq=-1;
rep(s,3,n){
vector<pii>lef;
rep(a,1,s-1)rep(b,a+1,s-1){
lef.pb({a,b});
}
shuffle(ALL(lef),Rnd);
for(auto[a,b]:lef){
w.reset();
w.set(tid[a][b]),w.set(tid[a][s]),w.set(tid[b][s]);
if(!ins(w))continue;
int v=ask(a,b,s);
if(eq==-1)eq=v;
else if(eq!=v)eq=-2;
if(v==0||v==3){
upd(tid[a][b],v>0);
upd(tid[a][s],v>0);
upd(tid[s][b],v>0);
}else{
}
if(rk==s*(s-1)/2){
// printf("#%d\n",s);
break;
}
}
if(s==n||(rk==s*(s-1)/2&&(eq==-2||eq==1||eq==2))){
static bit a[20000];
int tot=0;
int L=s*(s-1)/2;
for(auto[x,y,z,v]:Q){
int i=tid[x][y],j=tid[x][z],k=tid[y][z];
if(v>0&&v<3){
if(v==1){
if(buk[i]==1||buk[j]==1||buk[k]==1){
if(buk[i]==-1)buk[i]=0;
if(buk[j]==-1)buk[j]=0;
if(buk[k]==-1)buk[k]=0;
}
}
if(v==2){
if(buk[i]==0||buk[j]==0||buk[k]==0){
if(buk[i]==-1)buk[i]=1;
if(buk[j]==-1)buk[j]=1;
if(buk[k]==-1)buk[k]=1;
}
}
if(buk[i]!=-1&&buk[j]!=-1&&buk[k]!=-1)continue;
tot++;
a[tot].set(i);
a[tot].set(j);
a[tot].set(k);
if(v&1)a[tot].set(L+1);
}
}
rep(i,1,L)if(buk[i]!=-1){
tot++;
a[tot].set(i);
if(buk[i])a[tot].set(L+1);
}
rep(i,1,L){
if(!a[i][i]){
rep(j,i+1,tot)if(a[j][i]){
swap(a[i],a[j]);break;
}
}
rep(j,i+1,tot)if(a[j][i]){
a[j].doit_suf(a[i],i);
// a[j]^=a[i];
}
}
per(i,L,1){
assert(a[i][i]);
buk[i]=a[i][L+1];
if(a[i][L+1]){
rep(j,1,i-1)if(a[j][i]){
a[j].flip(L+1);
}
}
}
// printf("!%d, %d\n",rk,use_q);
rep(t,s+1,n){
vector<pii>o;
int lst=-1;
rep(i,1,t-1){
if(lst==-1){
lst=i;continue;
}
int v=ask(lst,i,t);
if(v==0||v==3){
buk[tid[lst][i]]=buk[tid[i][t]]=buk[tid[lst][t]]=v>0;
lst=-1;
}else if(v%2==buk[tid[lst][i]]){
buk[tid[i][t]]=buk[tid[lst][t]]=!(v%2);
lst=-1;
}else{
o.pb({lst,i});
}
}
if(lst!=-1){
rep(i,1,t-1)if(i!=lst){
bool can=1;
for(auto[a,b]:o){
if(lst==a)can&=i!=b;
if(lst==b)can&=i!=a;
}
if(!can)continue;
assert(buk[tid[i][t]]!=-1);
int v=ask(lst,i,t);
buk[tid[lst][t]]=v-buk[tid[lst][i]]-buk[tid[i][t]];
break;
}
assert(lst!=-1);
}
reverse(ALL(o));
for(auto[a,b]:o)buk[tid[b][t]]=!buk[tid[a][t]];
}
break;
}
}
if(eq==0){
rep(i,1,m)buk[i]=0;
}else if(eq==3){
rep(i,1,m)buk[i]=1;
}
rep(i,1,n)rep(j,i+1,n)ans[i][j]=ans[j][i]=buk[tid[i][j]];
answer();
}
signed main(){
// int T;cin>>T;while(T--)solve();
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 87.4452
Acceptable Answer
time: 73ms
memory: 10088kb
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:
? 50 63 93 ? 63 93 3 ? 50 63 3 ? 63 3 95 ? 93 3 95 ? 50 63 95 ? 3 95 25 ? 50 93 25 ? 63 3 25 ? 3 95 70 ? 95 25 70 ? 93 95 70 ? 50 25 70 ? 50 63 70 ? 25 70 23 ? 50 93 23 ? 93 3 23 ? 3 95 23 ? 63 70 23 ? 50 95 5 ? 95 70 5 ? 95 25 5 ? 63 3 5 ? 50 93 5 ? 93 23 5 ? 95 23 15 ? 70 23 15 ? 50 93 15 ? 93 5 1...
result:
points 0.87445161290 points 0.87445161290 correct 3678 queries
Test #2:
score: 85.5484
Acceptable Answer
time: 85ms
memory: 11232kb
input:
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...
output:
? 32 57 100 ? 57 100 99 ? 32 100 99 ? 57 99 43 ? 100 99 43 ? 32 99 43 ? 57 43 35 ? 32 99 35 ? 32 100 35 ? 57 35 5 ? 100 43 5 ? 32 35 5 ? 99 35 5 ? 57 35 68 ? 35 5 68 ? 99 43 68 ? 100 43 68 ? 32 35 68 ? 5 68 42 ? 32 35 42 ? 43 35 42 ? 57 43 42 ? 100 5 42 ? 99 43 42 ? 43 5 28 ? 100 68 28 ? 32 5 28 ? 9...
result:
points 0.8554838710 points 0.8554838710 correct 3720 queries
Test #3:
score: 100
Accepted
time: 62ms
memory: 9520kb
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:
? 87 5 41 ? 87 41 10 ? 5 41 10 ? 41 10 65 ? 5 41 65 ? 87 10 65 ? 87 41 71 ? 10 65 71 ? 5 65 71 ? 65 71 95 ? 87 5 95 ? 41 65 95 ? 10 65 95 ? 87 5 86 ? 71 95 86 ? 87 41 86 ? 41 10 86 ? 87 65 86 ? 71 86 58 ? 41 86 58 ? 87 10 58 ? 87 65 58 ? 5 10 58 ? 71 95 58 ? 71 86 93 ? 87 10 93 ? 87 95 93 ? 87 41 93...
result:
points 1.0 points 1.0 correct 3238 queries
Test #4:
score: 100
Accepted
time: 32ms
memory: 10348kb
input:
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...
output:
? 6 30 60 ? 6 30 59 ? 6 60 59 ? 6 59 72 ? 6 60 72 ? 6 30 72 ? 60 72 22 ? 59 72 22 ? 30 60 22 ? 6 30 22 ? 59 22 4 ? 30 22 4 ? 72 22 4 ? 60 72 4 ? 6 30 4 ? 6 4 69 ? 59 4 69 ? 6 72 69 ? 60 22 69 ? 30 59 69 ? 30 72 3 ? 6 4 3 ? 72 22 3 ? 59 22 3 ? 60 72 3 ? 60 69 3 ? 6 59 39 ? 60 59 39 ? 6 72 39 ? 6 30 3...
result:
points 1.0 points 1.0 correct 3090 queries
Test #5:
score: 100
Accepted
time: 9ms
memory: 5988kb
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 1 1 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 1 0 0 0 0 1 0 0 0 0 ...
output:
? 39 7 27 ? 39 27 20 ? 7 27 20 ? 7 20 40 ? 39 20 40 ? 39 27 40 ? 39 40 80 ? 27 20 80 ? 7 27 80 ? 7 80 42 ? 7 20 42 ? 39 40 42 ? 7 27 42 ? 7 27 18 ? 20 40 18 ? 7 80 18 ? 27 42 18 ? 39 80 18 ? 39 7 15 ? 7 40 15 ? 40 42 15 ? 42 18 15 ? 27 80 15 ? 20 80 15 ? 39 18 2 ? 27 18 2 ? 7 15 2 ? 39 80 2 ? 20 42 ...
result:
points 1.0 points 1.0 correct 2581 queries
Test #6:
score: 0
Wrong Answer
time: 1ms
memory: 5856kb
input:
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...
output:
? 88 62 74 ? 88 62 3 ? 62 74 3 ? 74 3 32 ? 88 62 32 ? 74 3 55 ? 62 3 55 ? 62 32 55 ? 88 32 55 ? 88 55 100 ? 3 32 100 ? 62 55 100 ? 74 32 100 ? 88 55 61 ? 62 55 61 ? 3 100 61 ? 88 74 61 ? 74 32 61 ? 74 61 30 ? 32 55 30 ? 74 100 30 ? 88 62 30 ? 74 3 30 ? 88 62 23 ? 74 3 23 ? 32 55 23 ? 100 61 23 ? 30 ...
result:
wrong answer the graph you report is incorrect