QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#116863 | #6668. Trokuti | Laurie# | 0 | 0ms | 0kb | C++14 | 4.4kb | 2023-06-30 09:32:39 | 2024-05-31 18:32:25 |
Judging History
answer
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <functional>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define itn int
#define nit int
#define ll long long
#define ms multiset
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define re register
#define ri re int
#define il inline
#define pii pair<int,int>
#define cp complex<double>
#define vi vector<int>
#define ull unsigned long long
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
using namespace std;
using std::bitset;
//using namespace __gnu_pbds;
const double Pi=acos(-1);
namespace fastIO {
template<class T>
inline void read(T &x) {
x=0;
bool fu=0;
char ch=0;
while(ch>'9'||ch<'0') {
ch=getchar();
if(ch=='-')fu=1;
}
while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
if(fu)x=-x;
}
inline int read() {
int x=0;
bool fu=0;
char ch=0;
while(ch>'9'||ch<'0') {
ch=getchar();
if(ch=='-')fu=1;
}
while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
return fu?-x:x;
}
template<class T,class... Args>
inline void read(T& t,Args&... args) {
read(t);
read(args...);
}
char _n_u_m_[40];
template<class T>
inline void write(T x) {
if(x==0){
putchar('0');
return;
}
T tmp = x > 0 ? x : -x ;
if( x < 0 ) putchar('-') ;
register int cnt = 0 ;
while( tmp > 0 ) {
_n_u_m_[ cnt ++ ] = tmp % 10 + '0' ;
tmp /= 10 ;
}
while( cnt > 0 ) putchar(_n_u_m_[ -- cnt ]) ;
}
template<class T>
inline void write(T x ,char ch) {
write(x);
putchar(ch);
}
}
using namespace fastIO;
int n=100,m=6;
int g[102][102],ans[102][102],qwq;
mt19937 rd(1234);
void init(){
F(i,1,n)F(j,i+1,n)ans[i][j]=ans[j][i]=rd()&1;
}
inline int query(int x,int y,int z){
++qwq;
printf("? %d %d %d\n",x,y,z);
fflush(stdout);
// return ans[x][y]+ans[y][z]+ans[x][z];
return read();
}
int id[102][102],cnt,A[100002],B[100002],C[100002],D[100002],tot,p[102];
void solve(){
F(i,1,m)F(j,1,i)g[i][j]=g[j][i];
F(i,m+1,n){
F(j,1,i-1)p[j]=j;
shuffle(p+1,p+i,rd);
vector<int>res;
int now=0;
while(now<i-1){
++now;
if(res.empty()){
res.push_back(p[now]);
++now;
}
if(now==i)break;
int v=query(res.back(),p[now],i)-g[res.back()][p[now]];
if(v==0){
g[i][p[now]]=0;
int now=0;
while(res.size()){
g[i][res.back()]=now;
now^=1;
res.pop_back();
}
}else if(v==2){
g[i][p[now]]=1;
int now=1;
while(res.size()){
g[i][res.back()]=now;
now^=1;
res.pop_back();
}
}else res.push_back(p[now]);
}
if(res.size()>=3){
if(query(res[0],res[2],i)<=1){
F(j,0,res.size()-1)g[i][res[j]]=(j&1);
}else{
F(j,0,res.size()-1)g[i][res[j]]=(j&1)^1;
}
}else if(res.size()){
int v=query(res.back(),p[0],i)-g[res.back()][p[0]]-g[i][p[0]];
if(v){
int now=1;
while(res.size()){
g[i][res.back()]=now;
now^=1;
res.pop_back();
}
}else{
int now=0;
while(res.size()){
g[i][res.back()]=now;
now^=1;
res.pop_back();
}
}
}
F(j,1,i-1)g[j][i]=g[i][j];
}
F(i,1,n)F(j,1,n)if(g[i][j]!=ans[i][j]){
cerr<<"WA"<<" "<<i<<" "<<j<<" "<<g[i][j]<<" "<<ans[i][j]<<endl;
return;
}
puts("!");
F(i,1,n){
F(j,1,n)putchar(g[i][j]+'0');
putchar('\n');
}
fflush(stdout);
cerr<<qwq<<endl;
}
inline bool check(){
F(i,1,tot)if(g[A[i]][B[i]]+g[B[i]][C[i]]+g[A[i]][C[i]]!=D[i]){
return false;
}
return true;
}
inline void dfs(int x,int y){
if(x==m){
if(check()){
solve();
exit(0);
}
}else{
g[x][y]=0;
if(y==m)dfs(x+1,x+2);
else dfs(x,y+1);
g[x][y]=1;
if(y==m)dfs(x+1,x+2);
else dfs(x,y+1);
}
}
int main() {
init();
F(i,1,n)F(j,i+1,n)id[i][j]=id[j][i]=++cnt;
F(i,1,m)F(j,i+1,m)F(k,j+1,m){
++tot;
A[tot]=i,B[tot]=j,C[tot]=k;
D[tot]=query(i,j,k);//cerr<<D[tot]<<endl;
}
dfs(1,2);
return 0;
}
詳細信息
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
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
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 ? 3 1 7 ? 2 4 7 ? 6 5 7 ? 1 4 8 ? 3 5 8 ? 7 2 8 ? 6 0 8