| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1352116 | Andrey | Toy Train (IOI17_train) | C++17 | 4 ms | 1504 KiB |
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5010;
vector<int> haha[MAXN];
vector<int> yeah[MAXN];
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
int n = a.size();
int m = u.size();
for(int i = 0; i < m; i++) {
haha[u[i]].push_back(v[i]);
yeah[v[i]].push_back(u[i]);
}
queue<int> idk;
vector<int> col(n);
for(int i = 0; i < n; i++) {
if(r[i]) {
idk.push(i);
}
}
vector<int> br(n);
while(!idk.empty()) {
int x = idk.front();
col[x] = 1;
idk.pop();
for(int v: yeah[x]) {
br[v]++;
if(a[v] == 1) {
if(br[v] == 1) {
idk.push(v);
}
}
else {
if(br[v] == haha[v].size()) {
idk.push(v);
}
}
}
}
while(!idk.empty()) {
idk.pop();
}
for(int i = 0; i < n; i++) {
br[i] = 0;
}
for(int i = 0; i < n; i++) {
if(col[i] == 0) {
idk.push(i);
}
}
while(!idk.empty()) {
int x = idk.front();
col[x] = 0;
idk.pop();
for(int v: yeah[x]) {
if(col[v] == 0) {
continue;
}
br[v]++;
if(a[v] == 0) {
if(br[v] == 1) {
idk.push(v);
}
}
else {
if(br[v] == haha[v].size()-1) {
idk.push(v);
}
}
}
}
return col;
}
| # | 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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
