제출 #412850

#제출 시각아이디문제언어결과실행 시간메모리
412850MasterTasterUnscrambling a Messy Bug (IOI16_messy)C++14
20 / 100
1 ms296 KiB
#include <bits/stdc++.h> #include "messy.h" #define pb push_back #define ll long long #define pii pair<int, int> #define xx first #define yy second using namespace std; vector<int> p; int xNady(int x, int y) { if (y==0) return 1; int ret=1; for (int i=x; i>x-y; i--) ret*=i; for (int i=y; i>0; i--) ret/=i; return ret; } std::vector<int> restore_permutation(int n, int w, int r) { if (n==8) { for (int i=0; i<7; i++) { for (int mask=0; mask<(1<<8); mask++) { if (__builtin_popcount(mask)!=i+1) continue; if (mask&(1<<i)) continue; string s="00000000"; for (int j=0; j<8; j++) if (mask&(1<<j)) s[j]='1'; else s[j]='0'; add_element(s); ///cout<<"dodajem "<<s<<endl; } } ///cout<<endl<<"kad obrnes:"<<endl; compile_set(); ///cout<<endl; int kolko[10]; for (int i=0; i<7; i++) { for (int j=0; j<8; j++) kolko[j]=0; for (int mask=0; mask<(1<<8); mask++) { if (__builtin_popcount(mask)!=i+1) continue; string s="00000000"; for (int j=0; j<8; j++) if (mask&(1<<j)) s[j]='1'; else s[j]='0'; bool dal=check_element(s); if (!dal) continue; ///cout<<s<<endl; for (int j=0; j<8; j++) if (mask&(1<<j)) kolko[j]++; if (mask&(1<<i)) { int drugi=-1; mask++; for (; mask<(1<<8); mask++) { if (__builtin_popcount(mask)!=i+1) continue; string s="00000000"; for (int j=0; j<8; j++) if (mask&(1<<j)) s[j]='1'; else s[j]='0'; bool dal=check_element(s); if (!dal) continue; for (int j=0; j<8; j++) if (mask&(1<<j)) kolko[j]++; } for (int j=0; j<8; j++) { if (j==i) continue; ///cout<<j<<" j kolko[j] "<<kolko[j]<<endl; if (kolko[j]!=xNady(6, i)) { drugi=j; break; } } //cout<<i<<" "<<drugi<<endl; for (int j=0; j<8; j++) { if (j!=i && j!=drugi) p.pb(j); else if (j==i) p.pb(drugi); else p.pb(i); } return p; } } } for (int i=0; i<8; i++) p.pb(i); return p; } /*add_element("0"); compile_set(); check_element("0"); return std::vector<int>();*/ } /* 8 256 256 0 1 2 6 4 5 3 7 */

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

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:104:1: warning: control reaches end of non-void function [-Wreturn-type]
  104 | }
      | ^
#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...