#include "train.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5000;
set<int> adj[N];
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();
bool simple = true;
for (int i = 0; i < m; i++)
{
if (!(v[i] == u[i] || v[i] == u[i] + 1)) simple = false;
adj[u[i]].insert(v[i]);
}
std::vector<int> res(a.size());
//cout << simple << endl;
if (simple)
{
for (int i = 0; i < n; i++)
{
int cur = i;
bool good = false;
int travelled = 0;
while (travelled < n)
{
if (a[cur] == 1)
{
if (r[cur] == 1)
{
if (adj[cur].find(cur) != adj[cur].end())
{
good = true;
break;
}
}
for (int next : adj[cur])
{
if (next != cur)
{
cur = next;
break;
}
}
} else
{
if (r[cur] != 1)
{
if (adj[cur].find(cur) != adj[cur].end())
{
break;
}
}
for (int next : adj[cur])
{
if (next != cur)
{
cur = next;
break;
}
}
}
travelled++;
}
if (r[cur]) good = true;
res[cur] = good;
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1100 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
460 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
1976 KB |
Output is correct |
2 |
Correct |
10 ms |
1996 KB |
Output is correct |
3 |
Correct |
10 ms |
1996 KB |
Output is correct |
4 |
Incorrect |
9 ms |
2084 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
1612 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
2080 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1100 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |