#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]]);
}
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 |
1 |
Correct |
0 ms |
348 KB |
n = 2 |
2 |
Correct |
0 ms |
348 KB |
n = 2 |
3 |
Correct |
0 ms |
348 KB |
n = 2 |
4 |
Correct |
0 ms |
348 KB |
n = 2 |
5 |
Correct |
0 ms |
600 KB |
n = 2 |
6 |
Incorrect |
0 ms |
344 KB |
answer is not correct: 1 instead of 523688153 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 2 |
2 |
Correct |
0 ms |
348 KB |
n = 2 |
3 |
Correct |
0 ms |
348 KB |
n = 2 |
4 |
Correct |
0 ms |
348 KB |
n = 2 |
5 |
Correct |
0 ms |
600 KB |
n = 2 |
6 |
Incorrect |
0 ms |
344 KB |
answer is not correct: 1 instead of 523688153 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
976 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 2 |
2 |
Correct |
0 ms |
348 KB |
n = 2 |
3 |
Correct |
0 ms |
348 KB |
n = 2 |
4 |
Correct |
0 ms |
348 KB |
n = 2 |
5 |
Correct |
0 ms |
600 KB |
n = 2 |
6 |
Incorrect |
0 ms |
344 KB |
answer is not correct: 1 instead of 523688153 |
7 |
Halted |
0 ms |
0 KB |
- |