Submission #429178

#TimeUsernameProblemLanguageResultExecution timeMemory
429178chirathnirodhaFinding Routers (IOI20_routers)C++17
60 / 100
3 ms296 KiB
//Coded by Chirath Nirodha #include<bits/stdc++.h> using namespace std; #include "routers.h" #define MP make_pair #define PB push_back #define F first #define S second typedef long long ll; vector<int> find_routers(int l, int n, int q) { vector<int> ans; if(n==2){ ll a=0,b=l; while(b-a>1){ ll m=(a+b)/2; int idx=use_detector(m); if(idx==0)a=m; else b=m; } ans.PB(0); ans.PB(2*a); } else{ int cur=1; ans.PB(0); for(int i=1;i<=l;i++){ int idx=use_detector(i); if(idx==cur){ ans.PB(ans[ans.size()-1]+(i-1-ans[ans.size()-1])*2); cur++; } if(ans.size()==n)break; } } return ans; }

Compilation message (stderr)

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:33:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |         if(ans.size()==n)break;
      |            ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...