Submission #88695

#TimeUsernameProblemLanguageResultExecution timeMemory
88695amiratouRoller Coaster Railroad (IOI16_railroad)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define fi first
#define se second
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vv vector<vector<int> >
#define pb push_back
#define INF 1555555
using namespace std;
vector<ii> vec,vec2;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
	//memset(matched,-1,sizeof matched);
    n = (int) s.size();
    speed=s;
    ex=t;
    for (int i = 0; i < n; ++i){
    	vec2.pb({t[i],i});
    	vec.pb({s[i],i});
    }
    sort(all(vec));
    int found_last=0,id;
    for (int i = 0; i < n; ++i)
    {
    	auto search=upper_bound(all(vec),make_pair(t[i],0));
    	if(search==vec.end()){
    		search--;
    		if(search->fi!=t[i]){if(!found_last){found_last++;tab[i]=-1;id=i;}else return INF;}
    		else{
    			tab[i]=(search-vec.begin());
    			//debug(tab[i]);
    			continue;
    		}
    	}
    	if(search==vec.begin()){
    		tab[i]=search-vec.begin();
    		continue;
    	}
    	search--;
    	if(search->fi!=t[i])search++;
    	tab[i]=(search-vec.begin());
    }
    sort(all(vec2));
    for (int i = 0; i < n; ++i)
    {
    	if((i)==(tab[vec2[i].se])||(i)==(tab[vec2[i].se]+1)||(i-1)==tab[vec2[i].se])
    		continue;
    	else return INF;
    }
    return 0;
    //return ((solve(0)==1)?0:INF);
}

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:21:5: error: 'n' was not declared in this scope
     n = (int) s.size();
     ^
railroad.cpp:22:5: error: 'speed' was not declared in this scope
     speed=s;
     ^~~~~
railroad.cpp:23:5: error: 'ex' was not declared in this scope
     ex=t;
     ^~
railroad.cpp:23:5: note: suggested alternative: 'exp'
     ex=t;
     ^~
     exp
railroad.cpp:35:57: error: 'tab' was not declared in this scope
       if(search->fi!=t[i]){if(!found_last){found_last++;tab[i]=-1;id=i;}else return INF;}
                                                         ^~~
railroad.cpp:35:57: note: suggested alternative: 'tan'
       if(search->fi!=t[i]){if(!found_last){found_last++;tab[i]=-1;id=i;}else return INF;}
                                                         ^~~
                                                         tan
railroad.cpp:37:8: error: 'tab' was not declared in this scope
        tab[i]=(search-vec.begin());
        ^~~
railroad.cpp:37:8: note: suggested alternative: 'tan'
        tab[i]=(search-vec.begin());
        ^~~
        tan
railroad.cpp:43:7: error: 'tab' was not declared in this scope
       tab[i]=search-vec.begin();
       ^~~
railroad.cpp:43:7: note: suggested alternative: 'tan'
       tab[i]=search-vec.begin();
       ^~~
       tan
railroad.cpp:48:6: error: 'tab' was not declared in this scope
      tab[i]=(search-vec.begin());
      ^~~
railroad.cpp:48:6: note: suggested alternative: 'tan'
      tab[i]=(search-vec.begin());
      ^~~
      tan
railroad.cpp:53:15: error: 'tab' was not declared in this scope
      if((i)==(tab[vec2[i].se])||(i)==(tab[vec2[i].se]+1)||(i-1)==tab[vec2[i].se])
               ^~~
railroad.cpp:53:15: note: suggested alternative: 'tan'
      if((i)==(tab[vec2[i].se])||(i)==(tab[vec2[i].se]+1)||(i-1)==tab[vec2[i].se])
               ^~~
               tan