Submission #361823

#TimeUsernameProblemLanguageResultExecution timeMemory
361823cheongmTreasure (different grader from official contest) (CEOI13_treasure2)C++14
56 / 100
1 ms512 KiB
#include "treasure.h" #include<cstdio> #include<vector> using namespace std; typedef pair<int,int> ii; typedef vector<ii> vii; int findTreasure(int r1, int c1, int r2, int c2, int remain,vii& v) { if(r1>r2||c1>c2) return 0; //printf("---- %d %d %d %d ----\n",r1,c1,r2,c2); int cnt,rval; if(remain) cnt = remain; else cnt = countTreasure(r1,c1,r2,c2); rval=cnt; if(cnt ==(r2-r1+1)*(c2-c1+1)) { for(int i=r1;i<=r2;i++) for(int j=c1;j<=c2;j++) { //printf("{%d,%d}\n",i,j); v.push_back(make_pair(i,j)); } } else if(cnt>0) { int rmid = (r1+r2)/2; int cmid = (c1+c2)/2; int is_full = false; cnt -=findTreasure(r1,c1,rmid,cmid,0,v); if((r2-rmid)*(c2-c1+1)+(rmid-r1+1)*(c2-cmid)==cnt) { findTreasure(rmid+1,c1,r2,cmid,(r2-rmid)*(cmid-c1+1),v); findTreasure(r1,cmid+1,rmid,c2,(rmid-r1+1)*(c2-cmid),v); findTreasure(rmid+1,cmid+1,r2,c2,(r2-rmid)*(c2-cmid),v); } else if(cnt>0) { cnt-=findTreasure(rmid+1,c1,r2,cmid,0,v); if((r2-r1+1)*(c2-cmid)==cnt) { findTreasure(r1,cmid+1,rmid,c2,(rmid-r1+1)*(c2-cmid),v); findTreasure(rmid+1,cmid+1,r2,c2,(r2-rmid)*(c2-cmid),v); } else if(cnt>0) { cnt-=findTreasure(r1,cmid+1,rmid,c2,0,v); if(cnt>0) findTreasure(rmid+1,cmid+1,r2,c2,cnt,v); } } } return rval; } void findTreasure (int N) { vii v; findTreasure(1,1,N,N,0,v); for(vii::iterator iter = v.begin(); iter!=v.end(); iter++) Report(iter->first,iter->second); }

Compilation message (stderr)

treasure.cpp: In function 'int findTreasure(int, int, int, int, int, vii&)':
treasure.cpp:34:13: warning: unused variable 'is_full' [-Wunused-variable]
   34 |         int is_full = false;
      |             ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...