Submission #429177

#TimeUsernameProblemLanguageResultExecution timeMemory
429177chirathnirodhaFinding Routers (IOI20_routers)C++17
Compilation error
0 ms0 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 p=0,q=l; while(q-p>1){ ll m=(p+q)/2; int idx=use_detector(m); if(idx==0)p=m; else q=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:22:16: error: 'a' was not declared in this scope
   22 |       ans.PB(2*a);
      |                ^
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;
      |            ~~~~~~~~~~^~~
routers.cpp:36:2: warning: no return statement in function returning non-void [-Wreturn-type]
   36 |  }
      |  ^
routers.cpp: At global scope:
routers.cpp:37:2: error: expected unqualified-id before 'return'
   37 |  return ans;
      |  ^~~~~~
routers.cpp:38:1: error: expected declaration before '}' token
   38 | }
      | ^