이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "Alice.h"
using namespace std;
int toggled[500];
int perm1[10000];
int perm2[10000];
int perm3[10000];
long long x;
long long len=4969;
set <int> rem;
vector <pair<int,int> > TVector;
vector <vector<int> > inGroup;
vector <pair<int,int> > TVector2;
vector <int> nums;
/*
long long setN(long long &n){
return 177013;
}*/
vector<pair <int,int>> Alice(){
setN(x);
//x=177013;
x^=463222221001217544;
//cout<<x<<"\n";
int toggledcnt=0;
inGroup.clear();
TVector.clear();
for(int i=0;i<=200;i++){
inGroup.push_back(nums);
toggled[i]=0;
}
for(int i=0;i<=60;i++){
if(x >> i & 1){
toggled[i]=1;
toggledcnt++;
}
}
for(int i=1;i<=len;i++){
perm1[i]=-1;
rem.insert(i);
inGroup[(i-1)/36].push_back(i);
}
//initialize the 1st perm;
for(int i=0;i<=60;i++){
if(toggled[i]){
for(int k=1;k<=9;k++){
perm1[i*9+k]=i;
}
for(int k=1;k<=9;k++){
rem.erase(i*36+k);
}
}
}
srand(123190);
for(int i=1;i<=len-1-toggledcnt*9;i++){
swap(perm1[i],perm1[rand()%(len-i-toggledcnt*9)+i]);
}
for(int i=1;i<=len-toggledcnt*9;i++){
// cout<<perm1[i]<<" ";
}
int cur=1,cur2=1,cur3=1;
for(int i=1;i<=len;i++){
if(rem.count(i)){
perm3[cur]=i;
cur++;
}
}
int ta,tb;
for(int i=0;i<=60;i++){
for(int k=1;k<=500;k++){
ta=rand()%36;
tb=rand()%36;
swap(inGroup[i][ta],inGroup[i][tb]);
}
}
cur--;
for(int i=2;i<cur;i++){
swap(perm3[i],perm3[rand()%(cur-i)+i+1]);
ta=(perm3[i]-1)/36;
tb=(perm3[i-1]-1)/36;
while(ta==tb&&(!toggled[ta]||ta>60)){
swap(perm3[i],perm3[rand()%(cur-i)+i+1]);
ta=(perm3[i]-1)/36;
tb=(perm3[i-1]-1)/36;
}
}
cur=1;
for(int i=1;i<=len-toggledcnt*9;i++){
if(perm1[i]>-1){
for(int k=0;k<4;k++){
perm2[cur]=inGroup[perm1[i]].back();
inGroup[perm1[i]].pop_back();
cur++;
}
}else{
perm2[cur]=perm3[cur2];
cur2++;
cur++;
}
}
for(int i=1;i<=len-1;i++){
// cout<<perm2[i]<<" ";
TVector.push_back({perm2[i],perm2[i+1]});
}
for(int i=0;i<=60;i++){
if(toggled[i]){
// cout<<i<<" ";
}
}
//cout<<"\n";
return TVector;
}
/*
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout<<(177013^463222221001217544)<<"\n";
cout<<x<<"\n";
TVector2=Alice();
for(int i=0;i<4800;i++){
// cout<<TVector2[i].first<<" "<<TVector2[i].second<<"\n";
}
}*/
#include <bits/stdc++.h>
#include "Bob.h"
//#include "apio24_magic_alice.cpp"
using namespace std;
int toggled2[500];
long long Bob(vector <pair<int,int> > adj){
for(int i=0;i<=200;i++){
toggled2[i]=0;
}
long long xorhash=463222221001217544,ta,tb,ans;
for(int i=0;i<adj.size();i++){
ta=(adj[i].first-1)/36;
tb=(adj[i].second-1)/36;
//cout<<adj[i].first<<" "<<adj[i].second<<"\n";
if(ta==tb&&ta<=60){
toggled2[ta]=1;
}
}
ans=0;
for(int i=0;i<=60;i++){
if(toggled2[i]){
//cout<<i<<" ";
ans|= 1ll << i;
}
}
ans^=xorhash;
return ans;
}
/*
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout<<Bob(Alice());
}*/
컴파일 시 표준 에러 (stderr) 메시지
Alice.cpp: In function 'std::vector<std::pair<int, int> > Alice()':
Alice.cpp:60:19: warning: unused variable 'cur3' [-Wunused-variable]
60 | int cur=1,cur2=1,cur3=1;
| ^~~~
Bob.cpp: In function 'long long int Bob(std::vector<std::pair<int, int> >)':
Bob.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | for(int i=0;i<adj.size();i++){
| ~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |