Submission #1110145

#TimeUsernameProblemLanguageResultExecution timeMemory
1110145StefanSebezMechanical Doll (IOI18_doll)C++14
18 / 100
48 ms10384 KiB
#include <bits/stdc++.h> #include "doll.h" using namespace std; #define fi first #define se second #define pb push_back #define ll long long #define ld long double const int lg=18; void create_circuit(int M, std::vector<int> A){ int n=A.size();A.pb(0); vector<int>C(M+1);C[0]=A[0]; vector<int>X,Y; if(M==1){ C[1]=-1; int x=n-1; for(int i=1;i<=lg;i++){ if((x>>(lg-i))&1==1){ X.pb(1); } else X.pb(-1); Y.pb(-i-1); } Y.back()=0; } else{ /*X.resize(M),Y.resize(M); for(int i=1;i<=M;i++)C[i]=-i;*/ vector<int>vals[M+50]; for(int i=0;i<n;i++) vals[A[i]].pb(A[i+1]); for(int i=1;i<=M;i++){ if(vals[i].size()==1) C[i]=vals[i][0]; if(vals[i].size()<=1) continue; int nc=X.size()+1; C[i]=-nc; if(vals[i].size()==2){ X.pb(vals[i][0]); Y.pb(vals[i][1]); } else if(vals[i].size()==3){ X.pb(-(nc+1)); Y.pb(-(nc+2)); X.pb(vals[i][0]); Y.pb(-nc); X.pb(vals[i][1]); Y.pb(vals[i][2]); } else{ X.pb(-(nc+1)); Y.pb(-(nc+2)); X.pb(vals[i][0]); Y.pb(vals[i][2]); X.pb(vals[i][1]); Y.pb(vals[i][3]); } } } //for(auto i:C) printf("%i ",i);printf("\n"); //for(int i=0;i<X.size();i++) printf("{%i %i}\n",X[i],Y[i]); answer(C,X,Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:18:20: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   18 |    if((x>>(lg-i))&1==1){
      |                   ~^~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...