Submission #296002

# Submission time Handle Problem Language Result Execution time Memory
296002 2020-09-10T07:24:47 Z Trickster Toy Train (IOI17_train) C++14
5 / 100
10 ms 1536 KB
#include "train.h"
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define N 5010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mod 1000000007
#define pii pair <int, int>
#define sz(a) int(a.size())
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
ll bigmod(ll a,ll e) {if(e==0)return 1;ll x=bigmod(a*a%mod,e>>1);return e&1?x*a%mod:x;}

int n, m;
int A[N];
int vis[N];
vector <int> E[N], T[N];

vector <int> who_wins(vector <int> a, vector <int> r, vector <int> u, vector <int> v)
{
    n = sz(a), m = sz(u);

    for(int i = 0; i < m; i++) E[u[i]].pb(v[i]), T[v[i]].pb(u[i]);

    queue <int> Q;
    for(int i = 0; i < n; i++) {
    	if(r[i] == 0) continue;

    	int ok = 0, ok2 = 1;
    	for(auto h: E[i]) {
    		if(i == h) ok = 1;
    		else ok2 = 0;
    	}

    	if(ok == 1 && (a[i] == 1 || ok2 == 1)) Q.push(i), vis[i] = 1;
    }

    while(!Q.empty()) {
    	int nd = Q.front();
    	Q.pop();

    	A[nd] = 1;
    	for(auto i: T[nd]) {
    		if(vis[i] == 1) continue;

    		int ok = 1;
    		if(a[i] == 0) for(auto j: E[i]) if(j == i) ok = 0;

    		if(ok == 1 || r[i] == 1) vis[i] = 1, Q.push(i);
    	}
    }

    vector <int> ret;
    for(int i = 0; i < n; i++) ret.pb(A[i]);

    return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1152 KB Output is correct
2 Correct 5 ms 1280 KB Output is correct
3 Correct 5 ms 1152 KB Output is correct
4 Correct 5 ms 1152 KB Output is correct
5 Correct 5 ms 1280 KB Output is correct
6 Correct 5 ms 1152 KB Output is correct
7 Correct 5 ms 1280 KB Output is correct
8 Correct 5 ms 1280 KB Output is correct
9 Correct 5 ms 1152 KB Output is correct
10 Correct 5 ms 1152 KB Output is correct
11 Correct 5 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 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 9 ms 1536 KB Output is correct
2 Correct 9 ms 1536 KB Output is correct
3 Correct 9 ms 1536 KB Output is correct
4 Incorrect 10 ms 1408 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1280 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 10 ms 1408 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 8 ms 1152 KB Output is correct
2 Correct 5 ms 1280 KB Output is correct
3 Correct 5 ms 1152 KB Output is correct
4 Correct 5 ms 1152 KB Output is correct
5 Correct 5 ms 1280 KB Output is correct
6 Correct 5 ms 1152 KB Output is correct
7 Correct 5 ms 1280 KB Output is correct
8 Correct 5 ms 1280 KB Output is correct
9 Correct 5 ms 1152 KB Output is correct
10 Correct 5 ms 1152 KB Output is correct
11 Correct 5 ms 1152 KB Output is correct
12 Incorrect 1 ms 512 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -