제출 #595324

#제출 시각아이디문제언어결과실행 시간메모리
595324Ahmadsm2005Unscrambling a Messy Bug (IOI16_messy)C++14
59 / 100
3 ms412 KiB
#include <bits/stdc++.h> #include "messy.h" //#include "grader.cpp" using namespace std; string arr[]={"0001","0010","0011","0100","0101","0110","0111","1001"}; int SZ[]={15,15,15,15,16,16,16,16},N,POS[]={-1,-1,-1,-1}; vector<int>YAY[8]; void SET(int CUR,int idx){ string S=""; S+=arr[CUR]; for(int i=4;i<N;i++) S+='0'; S[idx]='1'; add_element(S); } void SET2(int CUR,int idx,int idx2){ string S="1111"; for(int i=4;i<N;i++) S+='0'; for(int i=idx2;i<=idx;i++) S[i]='1'; add_element(S); } void SET3(string &s,int X){ for(int i=0;i<4;i++){ s[POS[i]]=arr[X][i]; } } vector<int> restore_permutation(int n, int w, int r){ N=n; vector<int>ANS(n); string s=""; for(int i=0;i<n;i++) s+='0'; s[0]='1'; add_element(s); s[1]='1'; add_element(s); s[2]='1'; add_element(s); s[3]='1'; add_element(s); int CUR=0,l=0; for(int i=4;i<n;i++){ SET(CUR,i); SET2(CUR,i,l); SZ[CUR]--; if(!SZ[CUR]) CUR++,l=i+1; } compile_set(); string SS=""; for(int i=0;i<n;i++){ SS+='0'; } for(int l=0;l<4;l++){ for(int i=0;i<n;i++){ if(SS[i]!='1'){ SS[i]='1'; if(check_element(SS)){ POS[l]=i; ANS[i]=l; break; } SS[i]='0'; } } } for(int i=0;i<n;i++){ if(POS[0]==i||POS[1]==i||POS[2]==i||POS[3]==i) continue; for(int l=0;l<7;l++){ string F=""; for(int z=0;z<n;z++) F+='0'; SET3(F,l); F[i]='1'; if(check_element(F)){ YAY[l].push_back(i); goto a; } } YAY[7].push_back(i); a:; } //for(int i=0;i<8;i++) //cout<<YAY[i].size()<<' '; //cout<<endl; int GC=4; for(int i=0;i<8;i++){ string F=""; for(int z=0;z<n;z++) F+='0'; F[POS[0]]=F[POS[1]]=F[POS[2]]=F[POS[3]]='1'; for(int x=0;x<YAY[i].size();x++){ for(int l=0;l<YAY[i].size();l++){ if(F[YAY[i][l]]=='0'){ F[YAY[i][l]]='1'; if(check_element(F)){ ANS[YAY[i][l]]=GC; GC++; break; } F[YAY[i][l]]='0'; } } } } vector<int>F; for(int i=0;i<n;i++) F.push_back(ANS[i]); //cout<<F.size()<<endl; return F; }

컴파일 시 표준 에러 (stderr) 메시지

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:95:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |     for(int x=0;x<YAY[i].size();x++){
      |                 ~^~~~~~~~~~~~~~
messy.cpp:96:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |     for(int l=0;l<YAY[i].size();l++){
      |                 ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...