Submission #748666

#TimeUsernameProblemLanguageResultExecution timeMemory
748666Username4132Pick (COI18_pick)C++14
60 / 100
1 ms340 KiB
#include<iostream> #include<vector> using namespace std; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define dforn(i, n) for(int i=n-1; i>=0; --i) #define PB push_back const int dx[8]={1, 1, 0, -1, -1, -1, 0, 1}, dy[8]={0, 1, 1, 1, 0, -1, -1, -1}; int cn[4]; vector<int> path; int orient(int dir, int ori){ if(ori==0) return dx[dir]>0? dir : dir^4; if(ori==1) return dy[dir]>0? dir : dir^4; if(ori==2) return dx[dir]<0? dir : dir^4; return dy[dir]<0? dir : dir^4; } int main(){ scanf("%d %d %d %d", cn, cn+2, cn+1, cn+3); if(!(cn[0] || cn[2])){ forn(i, cn[1]/2) path.PB(1); forn(i, cn[3]/2) path.PB(3); path.PB(5); forn(i, (cn[3]/2) - 1) path.PB(7); forn(i, (cn[1]/2) - 1) path.PB(5); path.PB(7); } else if((cn[1]^cn[3])&1){ int di[2][2], fi[2], ori[2], dir; if(cn[1]&1) di[0][0]=1, di[0][1]=2, di[1][0]=0, di[1][1]=3, fi[0]=0, fi[1]=2, ori[0]=3, ori[1]=0, dir=5; else di[0][0]=3, di[0][1]=0, di[1][0]=1, di[1][1]=2, fi[0]=6, fi[1]=0, dir=3; forn(w, 2){ forn(i, 2) forn(j, cn[di[w][i]]/2) path.PB(orient(di[w][i], ori[w])); path.PB(fi[w]); dforn(i, 2) forn(j, cn[di[w][i]]/2) path.PB(orient(di[w][i], ori[w]^2)); } path.PB(dir); } else{ int fi=0, se, fcn, scn, dir=cn[0]? 0 : 6, ind=cn[0]? 0 : 2, ori=cn[0]? 1 : 0; if(cn[1]&1){ fi = cn[0]? 1 : 7; se = cn[0]? 7 : 5; fcn = cn[ind]/2 - 1; scn = cn[ind]/2 + 1; --cn[1], --cn[3]; } else{ for(; fi<4; ++fi) if(fi!=ind && cn[fi]) break; cn[fi]-=2; fi = orient(fi, 1); se = orient(fi, 3); fcn = scn = cn[ind]/2; } cn[ind]=0; forn(i, fcn) path.PB(dir); path.PB(fi); forn(i, 4) forn(j, cn[i]/2) path.PB(orient(i, ori)); path.PB(dir^4); dforn(i, 4) forn(j, cn[i]/2) path.PB(orient(i, ori^2)); forn(i, scn-1) path.PB(dir^4); path.PB(se); } int x=0, y=0; for(int el:path){ printf("%d %d\n", x, y); x+=dx[el], y+=dy[el]; } }

Compilation message (stderr)

pick.cpp: In function 'int main()':
pick.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d %d %d %d", cn, cn+2, cn+1, cn+3);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...