QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#126522 | #6668. Trokuti | angry_face | 0 | 22ms | 6012kb | C++14 | 3.9kb | 2023-07-18 16:03:20 | 2023-07-18 16:03:24 |
Judging History
answer
# include <iostream>
# include <cstdio>
# include <vector>
# include <ctime>
# include <algorithm>
using namespace std ;
int n = 100 , a[205][205] , num[205][205] ;
int p[205] , st[205] ;
int cnt , x1 , x2 , x3 , cntq , q[205] ;
int f[205][205][205];
int ans ;
vector < int > vec ;
int query( int x , int y , int z )
{
cnt++ ;
printf("? %d %d %d\n" , x , y , z) ;
fflush( stdout ) ;
int t ;
scanf("%d" , &t) ;
return t ;
}
int solve(int u,int v,int w)
{
x1 = ( u - v + w ) / 2 ;
x2 = v - x1 ;
x3 = w - x1 ;
}
int main()
{
srand( time( 0 ) ) ;
// for ( int i = 1 ; i <= n ; i++ )
// for ( int j = i + 1 ; j <= n ; j++ ) a[i][j] = a[j][i] = rand() % 2 ;
for ( int i = 1 ; i <= n ; i++ ) p[i] = i ;
random_shuffle( p + 1 , p + n + 1 ) ;
for ( int i = 1 ; i <= 6 ; i++ )
for ( int j = i + 1 ; j <= 6 ; j++ )
for ( int k = j + 1 ; k <= 6 ; k++ )
{
if ( vec.size() ) continue ;
ans = query( p[i] , p[j] , p[k] ) ;
f[i][j][k]=ans;
if ( ! ans )
{
//vec.push_back( p[i] ) , vec.push_back( p[j] ) , vec.push_back( p[k] ) ;
//st[p[i]] = st[p[j]] = st[p[k]] = 1;
}
else if ( ans == 3 )
{
//vec.push_back( p[i] ) , vec.push_back( p[j] ) , vec.push_back( p[k] ) ;
//st[p[i]] = st[p[j]] = st[p[k]] = 1;
//num[p[i]][p[j]] = num[p[j]][p[i]] = num[p[i]][p[k]] = num[p[k]][p[i]] = num[p[j]][p[k]] = num[p[k]][p[j]] = 1 ;
}
}
for(int i=1;i<=6;i++) st[p[i]]=1;
for(int i=1;i<=6;i++) vec.push_back(p[i]);
for(int s=0;s<(1<<15);s++)
{
int cur=0;
for(int j=1;j<=6;j++)
{
for(int k=j+1;k<=6;k++)
{
if((s&(1<<cur))==0) num[p[j]][p[k]]=num[p[k]][p[j]]=0;
else num[p[j]][p[k]]=num[p[k]][p[j]]=1;
cur++;
}
}
bool flag=true;
for(int i=1;i<=6;i++)
{
for(int j=i+1;j<=6;j++)
{
for(int k=j+1;k<=6;k++)
{
int now=0;
if(num[p[i]][p[j]]==1) now++;
if(num[p[k]][p[j]]==1) now++;
if(num[p[i]][p[k]]==1) now++;
if(now!=f[i][j][k]) flag=false;
}
}
}
if(flag==true) break;
}
for ( int i = 1 ; i <= n ; i++ )
{
if ( st[p[i]] ) continue ;
cntq =0 ;
for ( auto j : vec ) q[++ cntq] = j ;
//random_shuffle( q + 1 , q + cntq + 1 ) ;
int tnum = 1 ;
while ( tnum + 2 <= cntq )
{
int ansb = query( p[i] , q[tnum] , q[tnum + 1] ) - num[q[tnum]][q[tnum + 1]] ;
if ( ansb == 0 || ansb == 2 )
{
num[p[i]][q[tnum]] = num[q[tnum]][p[i]] = num[p[i]][q[tnum + 1]] = num[q[tnum + 1]][p[i]] = ansb / 2 ;
tnum += 2 ;
continue ;
}
int nbc = query( p[i] , q[tnum + 1] , q[tnum + 2] ) - num[q[tnum + 1]][q[tnum + 2]] ;
if ( nbc == 0 || nbc == 2 )
{
num[p[i]][q[tnum + 1]] = num[q[tnum + 1]][p[i]] = num[p[i]][q[tnum + 2]] = num[q[tnum + 2]][p[i]] = nbc / 2 ;
num[p[i]][q[tnum]] = num[q[tnum]][p[i]] = ansb - num[p[i]][q[tnum + 1]] ;
tnum += 3 ;
continue ;
}
int ansc = query( p[i] , q[tnum] , q[tnum + 2] ) - num[q[tnum]][q[tnum + 2]] ;
solve( ansb , nbc , ansc ) ;
num[p[i]][q[tnum]] = num[q[tnum]][p[i]] = x1 ;
num[p[i]][q[tnum + 1]] = num[q[tnum + 1]][p[i]] = x2 ;
num[p[i]][q[tnum + 2]] = num[q[tnum + 2]][p[i]] = x3 ;
tnum += 3 ;
}
if ( tnum <= cntq )
{
num[p[i]][q[tnum]] = num[q[tnum]][p[i]] = query( p[i] , q[tnum - 1] , q[tnum] ) - num[p[i]][q[tnum - 1]] - num[q[tnum - 1]][q[tnum]] ;
}
if ( tnum + 1 <= cntq )
{
num[p[i]][q[tnum + 1]] = num[q[tnum + 1]][p[i]] = query( p[i] , q[tnum - 1] , q[tnum + 1] ) - num[p[i]][q[tnum - 1]] - num[q[tnum - 1]][q[tnum + 1]] ;
}
vec.push_back( p[i] ) ;
st[p[i]] = true ;
}
// for ( int i = 1 ; i <= n ; i++ )
// for ( int j = i + 1 ; j <= n ; j++ )
// {
// if ( num[i][j] != a[i][j] )
// {
// printf("GG:%d %d\n" , i , j) ;
// }
// }
puts("!") ;
for ( int i = 1 ; i <= n ; i++ )
{
for ( int j = 1 ; j <= n ; j++ ) printf("%d" , num[i][j]) ;
puts("") ;
}
fflush( stdout ) ;
return 0 ;
}
詳細信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 100
Accepted
time: 19ms
memory: 6012kb
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:
? 53 59 12 ? 53 59 38 ? 53 59 81 ? 53 59 86 ? 53 12 38 ? 53 12 81 ? 53 12 86 ? 53 38 81 ? 53 38 86 ? 53 81 86 ? 59 12 38 ? 59 12 81 ? 59 12 86 ? 59 38 81 ? 59 38 86 ? 59 81 86 ? 12 38 81 ? 12 38 86 ? 12 81 86 ? 38 81 86 ? 10 53 59 ? 10 12 38 ? 10 38 81 ? 10 38 86 ? 82 53 59 ? 82 12 38 ? 82 81 86 ? 8...
result:
points 1.0 points 1.0 correct 2558 queries
Test #2:
score: 100
Accepted
time: 14ms
memory: 3836kb
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:
? 41 65 10 ? 41 65 97 ? 41 65 49 ? 41 65 92 ? 41 10 97 ? 41 10 49 ? 41 10 92 ? 41 97 49 ? 41 97 92 ? 41 49 92 ? 65 10 97 ? 65 10 49 ? 65 10 92 ? 65 97 49 ? 65 97 92 ? 65 49 92 ? 10 97 49 ? 10 97 92 ? 10 49 92 ? 97 49 92 ? 63 41 65 ? 63 10 97 ? 63 97 49 ? 63 97 92 ? 53 41 65 ? 53 10 97 ? 53 49 92 ? 5...
result:
points 1.0 points 1.0 correct 2558 queries
Test #3:
score: 100
Accepted
time: 22ms
memory: 3752kb
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:
? 41 65 10 ? 41 65 97 ? 41 65 49 ? 41 65 92 ? 41 10 97 ? 41 10 49 ? 41 10 92 ? 41 97 49 ? 41 97 92 ? 41 49 92 ? 65 10 97 ? 65 10 49 ? 65 10 92 ? 65 97 49 ? 65 97 92 ? 65 49 92 ? 10 97 49 ? 10 97 92 ? 10 49 92 ? 97 49 92 ? 63 41 65 ? 63 10 97 ? 63 97 49 ? 63 97 92 ? 53 41 65 ? 53 10 97 ? 53 49 92 ? 5...
result:
points 1.0 points 1.0 correct 2558 queries
Test #4:
score: 100
Accepted
time: 10ms
memory: 5988kb
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:
? 41 65 10 ? 41 65 97 ? 41 65 49 ? 41 65 92 ? 41 10 97 ? 41 10 49 ? 41 10 92 ? 41 97 49 ? 41 97 92 ? 41 49 92 ? 65 10 97 ? 65 10 49 ? 65 10 92 ? 65 97 49 ? 65 97 92 ? 65 49 92 ? 10 97 49 ? 10 97 92 ? 10 49 92 ? 97 49 92 ? 63 41 65 ? 63 10 97 ? 63 97 49 ? 63 97 92 ? 53 41 65 ? 53 10 97 ? 53 49 92 ? 5...
result:
points 1.0 points 1.0 correct 2558 queries
Test #5:
score: 0
Runtime Error
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:
? 96 16 31 ? 96 16 38 ? 96 16 60 ? 96 16 51 ? 96 31 38 ? 96 31 60 ? 96 31 51 ? 96 38 60 ? 96 38 51 ? 96 60 51 ? 16 31 38 ? 16 31 60 ? 16 31 51 ? 16 38 60 ? 16 38 51 ? 16 60 51 ? 31 38 60 ? 31 38 51 ? 31 60 51 ? 38 60 51 ? 94 96 16 ? 94 31 38 ? 94 38 60 ? 94 38 51 ? 66 96 16 ? 66 31 38 ? 66 60 51 ? 6...