이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include<interactive.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll>pll;
typedef long double ld;
ll bin_pow(ll a,ll b){
if(b==0)return 1;
if(b%2==0){
ll t=bin_pow(a,b/2);
return t*t%MOD;
}
else return a*bin_pow(a,b-1)%MOD;
}
vector<int> guess(int n){
vector<int>a(n);
for(int i=0;i<=n-4;i+=4){
int x=ask(i+1);
a[i]=x;
vector<int>c,y;
c.push_back(i+1);
c.push_back(i+2);
c.push_back(i+3);
c.push_back(i+4);
y=get_pairwise_xor(c);
map<ll,ll>mp;
for(auto u : y)mp[u]++;
y.clear();
mp[0]-=4;
for(auto u : mp){
for(int i=0;i<u.second/2;i++)y.push_back(u.first);
}
do{
int m=y.size();
int b=y[0]^x;
int c=y[1]^x;
int d=y[2]^x;
if((y[3]==(b^c))&&(y[4]==(b^d))&&(y[5]==(c^d))){
a[i+1]=b;
a[i+2]=c;
a[i+3]=d;
break;
}
else continue;
}while(next_permutation(y.begin(),y.end()));
}
if(n%4!=0){
int x=a[n-n%4-1];
ll i=n-n%4-1;
vector<int>c,y;
c.push_back(i+1);
c.push_back(i+2);
c.push_back(i+3);
c.push_back(i+4);
y=get_pairwise_xor(c);
map<ll,ll>mp;
for(auto u : y)mp[u]++;
y.clear();
mp[0]-=4;
for(auto u : mp){
for(int i=0;i<u.second/2;i++)y.push_back(u.first);
}
do{
int m=y.size();
int b=y[0]^x;
int c=y[1]^x;
int d=y[2]^x;
if((y[3]==(b^c))&&(y[4]==(b^d))&&(y[5]==(c^d))){
a[i+1]=b;
a[i+2]=c;
a[i+3]=d;
break;
}
else continue;
}while(next_permutation(y.begin(),y.end()));
}
return a;
}
컴파일 시 표준 에러 (stderr) 메시지
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:36:17: warning: unused variable 'm' [-Wunused-variable]
36 | int m=y.size();
| ^
Xoractive.cpp:66:17: warning: unused variable 'm' [-Wunused-variable]
66 | int m=y.size();
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |