# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
405748 |
2021-05-16T21:17:00 Z |
peuch |
Toy Train (IOI17_train) |
C++17 |
|
11 ms |
1436 KB |
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 10;
int n;
vector<int> ar[MAXN];
vector<int> sub1(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v){
vector<int> w(n, 0);
for(int i = n - 1; i >= 0; i--){
if(ar[i].size() == 2){
if(a[i]){
if(r[i]) w[i] = 1;
else w[i] = w[i + 1];
}
else{
if(r[i]) w[i] = w[i + 1];
else w[i] = 0;
}
}
else if(ar[i][0] == i) w[i] = r[i];
else w[i] = w[i + 1];
}
return w;
}
vector<int> sub2(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v);
vector<int> sub3(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v);
vector<int> sub4(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v);
vector<int> sub5(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v);
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
n = a.size();
for(int i = 0; i < u.size(); i++)
ar[u[i]].push_back(v[i]);
return sub1(a, r, u, v);
if(n <= 15) return sub2(a, r, u, v);
bool flag = true;
for(int i = 0; i < n; i++)
flag &= a[i];
if(flag) return sub3(a, r, u, v);
flag = true;
for(int i = 0; i < n; i++)
flag &= !a[i];
if(flag) return sub4(a, r, u, v);
int cnt = 0;
for(int i = 0; i < n; i++)
cnt += r[i];
if(cnt == 1) return sub5(a, r, u, v);
return sub1(a, r, u, v);
}
Compilation message
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i = 0; i < u.size(); i++)
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
844 KB |
Output is correct |
2 |
Correct |
4 ms |
844 KB |
Output is correct |
3 |
Correct |
5 ms |
844 KB |
Output is correct |
4 |
Correct |
4 ms |
844 KB |
Output is correct |
5 |
Correct |
5 ms |
944 KB |
Output is correct |
6 |
Correct |
5 ms |
844 KB |
Output is correct |
7 |
Correct |
4 ms |
844 KB |
Output is correct |
8 |
Correct |
4 ms |
844 KB |
Output is correct |
9 |
Correct |
4 ms |
920 KB |
Output is correct |
10 |
Correct |
4 ms |
844 KB |
Output is correct |
11 |
Correct |
4 ms |
844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1244 KB |
Output is correct |
2 |
Correct |
7 ms |
1436 KB |
Output is correct |
3 |
Correct |
10 ms |
1356 KB |
Output is correct |
4 |
Incorrect |
8 ms |
1356 KB |
3rd lines differ - on the 182nd token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
1100 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
1200 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
844 KB |
Output is correct |
2 |
Correct |
4 ms |
844 KB |
Output is correct |
3 |
Correct |
5 ms |
844 KB |
Output is correct |
4 |
Correct |
4 ms |
844 KB |
Output is correct |
5 |
Correct |
5 ms |
944 KB |
Output is correct |
6 |
Correct |
5 ms |
844 KB |
Output is correct |
7 |
Correct |
4 ms |
844 KB |
Output is correct |
8 |
Correct |
4 ms |
844 KB |
Output is correct |
9 |
Correct |
4 ms |
920 KB |
Output is correct |
10 |
Correct |
4 ms |
844 KB |
Output is correct |
11 |
Correct |
4 ms |
844 KB |
Output is correct |
12 |
Incorrect |
1 ms |
332 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
13 |
Halted |
0 ms |
0 KB |
- |