# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1039203 | 2024-07-30T14:29:52 Z | Soumya1 | 장난감 기차 (IOI17_train) | C++17 | 10 ms | 3420 KB |
#include "train.h" #include <bits/stdc++.h> using namespace std; const int mxN = 5005; set<int> ad[mxN], rev[mxN]; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { int n = a.size(); for (int i = 0; i < u.size(); i++) { ad[u[i]].insert(v[i]); rev[v[i]].insert(u[i]); } auto get = [&](vector<int> s) { vector<int> out(n), vis(n); for (int i : s) vis[i] = true; for (int i = 0; i < s.size(); i++) { int u = s[i]; for (int v : rev[u]) { out[v]++; if (!vis[v] && out[v] >= (a[v] ? 1 : ad[v].size())) { s.push_back(v); vis[v] = true; } } } return s; }; vector<bool> removed(n); while (true) { vector<int> on; for (int i = 0; i < n; i++) { if (r[i] && !removed[i]) on.push_back(i); } vector<bool> can(n); on = get(on); for (int i : on) can[i] = true; vector<int> bad; for (int i = 0; i < n; i++) { if (!removed[i] && !can[i]) bad.push_back(i); } bad = get(bad); if (bad.empty()) break; for (int i : bad) { removed[i] = true; ad[i].clear(); for (int j : rev[i]) ad[j].erase(i); rev[i].clear(); } } vector<int> ans(n); for (int i = 0; i < n; i++) ans[i] = !removed[i]; return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 1884 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 856 KB | 3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 3420 KB | Output is correct |
2 | Correct | 8 ms | 3308 KB | Output is correct |
3 | Correct | 8 ms | 3420 KB | Output is correct |
4 | Incorrect | 10 ms | 3420 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2652 KB | 3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 3420 KB | 3rd lines differ - on the 4th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 1884 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |