제출 #469325

#제출 시각아이디문제언어결과실행 시간메모리
469325luciocfRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
784 ms40936 KiB
#include <bits/stdc++.h> #include "railroad.h" using namespace std; const int maxn = 4e5+10; map<int, int> mp; int soma[maxn]; bool mark[maxn]; vector<int> grafo[maxn]; void dfs(int u) { mark[u] = 1; for (auto v: grafo[u]) if (!mark[v]) dfs(v); } long long plan_roller_coaster(vector<int> s, vector<int> t) { int n = (int) s.size(); mp[1] = mp[1e9] = 0; for (int i = 0; i < n; i++) mp[s[i]] = mp[t[i]] = 0; int aux = 0; for (auto &x: mp) x.second = aux++; vector<int> v; for (int i = 0; i < n; i++) { soma[mp[s[i]]]++; soma[mp[t[i]]]--; v.push_back(mp[s[i]]); v.push_back(mp[t[i]]); grafo[mp[s[i]]].push_back(mp[t[i]]); } soma[mp[1]]++, soma[mp[1e9]]++; for (int i = 0; i < aux; i++) { if (i) soma[i] += soma[i-1]; if (soma[i] > 0) return 1; else if (soma[i] < 0) grafo[i].push_back(i+1); } dfs(0); for (int i = 0; i < aux; i++) if (!mark[i]) return 1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...