QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#117183#6668. TrokutiIrisu0 104ms12032kbC++176.2kb2023-06-30 16:16:152023-06-30 16:16:16

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-30 16:16:16]
  • 评测
  • 测评结果:0
  • 用时:104ms
  • 内存:12032kb
  • [2023-06-30 16:16:15]
  • 提交

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||((s>10||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]];
            lst=-1;
            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
Dangerous Syscalls

Test #1:

score: 86.4065
Acceptable Answer
time: 104ms
memory: 12032kb

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:

? 37 78 48
? 78 48 55
? 37 48 55
? 37 48 91
? 48 55 91
? 37 78 91
? 37 55 96
? 37 91 96
? 37 48 96
? 37 78 96
? 48 91 98
? 48 55 98
? 37 91 98
? 37 78 98
? 91 96 98
? 91 98 97
? 37 96 97
? 37 48 97
? 78 98 97
? 37 55 97
? 91 97 34
? 37 97 34
? 48 96 34
? 78 48 34
? 55 91 34
? 98 97 34
? 55 98 44
? 9...

result:

points 0.86406451610 points  0.86406451610 correct 3701 queries

Test #2:

score: 86.9935
Acceptable Answer
time: 76ms
memory: 10596kb

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:

? 38 9 26
? 9 26 67
? 38 26 67
? 26 67 85
? 38 67 85
? 9 67 85
? 9 67 53
? 9 26 53
? 26 85 53
? 38 67 53
? 67 53 51
? 38 26 51
? 38 9 51
? 26 85 51
? 38 85 52
? 38 9 52
? 26 85 52
? 9 53 52
? 67 53 52
? 85 51 52
? 67 52 93
? 9 67 93
? 9 53 93
? 38 9 93
? 9 85 93
? 38 51 93
? 26 52 93
? 9 52 18
? 26 ...

result:

points 0.86993548390 points  0.86993548390 correct 3688 queries

Test #3:

score: 100
Accepted
time: 93ms
memory: 9948kb

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:

? 62 75 24
? 75 24 44
? 62 24 44
? 24 44 51
? 75 24 51
? 62 44 51
? 75 51 47
? 24 44 47
? 62 24 47
? 24 44 32
? 62 24 32
? 75 44 32
? 62 47 32
? 75 51 32
? 47 32 40
? 62 32 40
? 44 47 40
? 24 32 40
? 24 51 40
? 75 47 40
? 51 47 67
? 44 47 67
? 75 24 67
? 62 32 67
? 24 40 67
? 47 67 80
? 51 40 80
? 7...

result:

points 1.0 points  1.0 correct 3315 queries

Test #4:

score: 100
Accepted
time: 61ms
memory: 10876kb

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:

? 63 33 89
? 63 33 79
? 63 89 79
? 63 89 66
? 33 89 66
? 63 79 66
? 33 89 11
? 63 89 11
? 89 66 11
? 33 79 11
? 66 11 2
? 33 79 2
? 63 11 2
? 89 66 2
? 79 66 24
? 89 11 24
? 63 89 24
? 63 33 24
? 79 2 24
? 89 24 20
? 66 24 20
? 79 11 20
? 63 89 20
? 33 2 20
? 63 2 54
? 11 20 54
? 89 24 54
? 33 66 54...

result:

points 1.0 points  1.0 correct 3302 queries

Test #5:

score: 100
Accepted
time: 18ms
memory: 6204kb

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:

? 39 31 86
? 31 86 22
? 39 86 22
? 31 86 73
? 39 22 73
? 39 86 42
? 31 86 42
? 39 73 42
? 22 73 42
? 73 42 68
? 22 73 68
? 39 22 68
? 39 31 68
? 39 86 68
? 31 42 83
? 73 42 83
? 39 68 83
? 86 22 83
? 31 22 56
? 39 22 56
? 68 83 56
? 73 68 56
? 39 86 56
? 39 42 56
? 73 42 10
? 83 56 10
? 22 42 10
? 8...

result:

points 1.0 points  1.0 correct 2697 queries

Test #6:

score: 0
Dangerous Syscalls

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:

? 21 32 68
? 21 68 34
? 32 68 34
? 21 32 74
? 32 34 74
? 68 34 74
? 21 74 67
? 21 68 67
? 32 34 67
? 68 34 27
? 21 32 27
? 68 67 27
? 34 74 27
? 68 74 35
? 34 74 35
? 67 27 35
? 21 74 35
? 32 34 35
? 68 27 30
? 67 35 30
? 32 35 30
? 21 74 30
? 68 34 30
? 21 30 40
? 34 30 40
? 21 32 40
? 74 30 40
? 2...

result: