Submission #203791

# Submission time Handle Problem Language Result Execution time Memory
203791 2020-02-22T07:50:04 Z anonymous Toy Train (IOI17_train) C++14
0 / 100
12 ms 1528 KB
#include "train.h"
#include<vector>
#include<iostream>
#define MAXN 1005
using namespace std;
int V,E;
bool can1[MAXN], can2[MAXN]; //uncharged forced path, forced path
vector <int> adj[MAXN];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	vector<int> res;
	V = a.size(), E=u.size();
	for (int i=0; i<E; i++) {
        adj[u[i]].push_back(v[i]);
	}

	for (int S=0; S<V; S++) {
        for (int e=0; e<E; e++) {
            if (r[u[e]] || r[v[e]] || a[u[e]]) {continue;}
            for (int i=0; i<V; i++) {
                can1[i] = can2[i] = 0;
            }
            can1[u[e]] = true, can2[v[e]] = true;
            for (int i=0; i<V; i++) { //phase
                for (int cur=0; cur<V; cur++) { //each node
                    if (a[cur]) { //charged guy
                        bool all1 = 1, all2 = 1;
                        for (auto to: adj[cur]) {
                            if (!can1[to]) {all1=false;}
                            if (!can2[to]) {all2=false;}
                        }
                        if (!r[cur] && all1) {can1[cur]=true;}
                        if (all2) {can2[cur]=true;}
                    } else {
                        bool has1 = 0, has2 = 0;
                        for (auto to: adj[cur]) {
                            if (can1[to]) {has1=true;}
                            if (can2[to]) {has2=true;}
                        }
                        if (!r[cur] && has1) {can1[cur]=true;}
                        if (has2) {can2[cur]=true;}
                    }
                }
            }
            if (can2[S] && can1[v[e]]) {
                res.push_back(0);
                break;
            }
        }
        if (res.size() == S) {
            res.push_back(1);
        }
	}
	return res;
}

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:50:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (res.size() == S) {
             ~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 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 Runtime error 11 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 1208 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 1528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -