Submission #429176

#TimeUsernameProblemLanguageResultExecution timeMemory
429176chirathnirodhaFinding 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) {
    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:20:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   20 |       ans.PB(0);
      |       ^~~
      |       abs
routers.cpp:21:16: error: 'a' was not declared in this scope
   21 |       ans.PB(2*a);
      |                ^
routers.cpp:25:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |       ans.PB(0);
      |       ^~~
      |       abs
routers.cpp:35:2: warning: no return statement in function returning non-void [-Wreturn-type]
   35 |  }
      |  ^
routers.cpp: At global scope:
routers.cpp:36:2: error: expected unqualified-id before 'return'
   36 |  return ans;
      |  ^~~~~~
routers.cpp:37:1: error: expected declaration before '}' token
   37 | }
      | ^