#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[i] = good;
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
972 KB |
Output is correct |
2 |
Correct |
6 ms |
1100 KB |
Output is correct |
3 |
Correct |
6 ms |
1100 KB |
Output is correct |
4 |
Correct |
6 ms |
1100 KB |
Output is correct |
5 |
Correct |
13 ms |
1100 KB |
Output is correct |
6 |
Correct |
23 ms |
1128 KB |
Output is correct |
7 |
Correct |
25 ms |
1100 KB |
Output is correct |
8 |
Correct |
21 ms |
1100 KB |
Output is correct |
9 |
Correct |
44 ms |
1100 KB |
Output is correct |
10 |
Correct |
70 ms |
1068 KB |
Output is correct |
11 |
Correct |
82 ms |
1004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1820 KB |
Output is correct |
2 |
Correct |
11 ms |
1884 KB |
Output is correct |
3 |
Correct |
11 ms |
1872 KB |
Output is correct |
4 |
Incorrect |
9 ms |
1868 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
1456 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
1868 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
972 KB |
Output is correct |
2 |
Correct |
6 ms |
1100 KB |
Output is correct |
3 |
Correct |
6 ms |
1100 KB |
Output is correct |
4 |
Correct |
6 ms |
1100 KB |
Output is correct |
5 |
Correct |
13 ms |
1100 KB |
Output is correct |
6 |
Correct |
23 ms |
1128 KB |
Output is correct |
7 |
Correct |
25 ms |
1100 KB |
Output is correct |
8 |
Correct |
21 ms |
1100 KB |
Output is correct |
9 |
Correct |
44 ms |
1100 KB |
Output is correct |
10 |
Correct |
70 ms |
1068 KB |
Output is correct |
11 |
Correct |
82 ms |
1004 KB |
Output is correct |
12 |
Incorrect |
1 ms |
460 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
13 |
Halted |
0 ms |
0 KB |
- |