Submission #122554

# Submission time Handle Problem Language Result Execution time Memory
122554 2019-06-28T15:21:00 Z SirCeness Toy Train (IOI17_train) C++14
5 / 100
9 ms 1536 KB
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;

list<int> adj[5003];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	for (int i = 0; i < u.size(); i++){
		adj[u[i]].pb(v[i]);
	}
	vector<int> ans(a.size());
	for (int i = a.size()-1; i >= 0; i--){
		int kendine = 0;
		int ileri = 0;
		for (list<int>::iterator it = adj[i].begin(); it != adj[i].end(); ++it){
			if (*it == i) kendine = 1;
			if (*it == i+1) ileri = 1;
		}
		if (kendine){
			if (a[i] == 1 && r[i] == 1){
				ans[i] = 1;
				continue;
			} else if (a[i] == 0 && r[i] == 0){
				ans[i] = 0;
				continue;
			}
		}
		if (!ileri){
			if (r[i] == 0) ans[i] = 0;
			else if (r[i] == 1) ans[i] = 1;
		} else {
			assert(i+1 != ans.size());
			ans[i] = ans[i+1];
		}
	}
	return ans;
	
}

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:11:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < u.size(); i++){
                  ~~^~~~~~~~~~
In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from train.cpp:1:
train.cpp:35:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    assert(i+1 != ans.size());
           ~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 896 KB Output is correct
2 Correct 5 ms 896 KB Output is correct
3 Correct 6 ms 1024 KB Output is correct
4 Correct 6 ms 1024 KB Output is correct
5 Correct 6 ms 896 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 6 ms 1024 KB Output is correct
8 Correct 5 ms 880 KB Output is correct
9 Correct 6 ms 896 KB Output is correct
10 Correct 5 ms 944 KB Output is correct
11 Correct 4 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1536 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1280 KB 3rd lines differ - on the 21st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1536 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 5 ms 896 KB Output is correct
2 Correct 5 ms 896 KB Output is correct
3 Correct 6 ms 1024 KB Output is correct
4 Correct 6 ms 1024 KB Output is correct
5 Correct 6 ms 896 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 6 ms 1024 KB Output is correct
8 Correct 5 ms 880 KB Output is correct
9 Correct 6 ms 896 KB Output is correct
10 Correct 5 ms 944 KB Output is correct
11 Correct 4 ms 896 KB Output is correct
12 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
13 Halted 0 ms 0 KB -