이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |