This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5+10;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9+7;
long long plan_roller_coaster(vector<int> s, vector<int> t) {
vector<int> arr;
for(auto u : s) arr.pb(u);
for(auto u : t) arr.pb(u);
sort(all(arr));
arr.erase(unique(all(arr)), arr.end());
int n=(int)arr.size();
map<int, int> mp;
vector<int> g(n, 0);
for(int i=0;i<n;i++) mp[arr[i]]=i;
vector<vector<int>> adj(n);
adj[n-1].pb(0);
g[n-1]++; g[0]--;
for(int i=0;i<(int)s.size();i++){
g[mp[s[i]]]++; g[mp[t[i]]]--;
adj[mp[s[i]]].pb(mp[t[i]]);
}
return 0;
for(int i=0;i<n-1;i++){
if(g[i]>0) return 1;
while(g[i]<0) adj[i].pb(i+1), g[i]++, g[i+1]--;
}
if(g[n-1]!=0) return 1;
vector<int> cmp(n, 0);
cmp[0]=1;
queue<int> q; q.push(0);
while(!q.empty()){
int curr=q.front();
q.pop();
for(auto u : adj[curr]){
if(!cmp[u]){
cmp[u]=1;
q.push(u);
}
}
}
for(int i=0;i<n;i++)
if(!cmp[i]) return 1;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |