Submission #669748

# Submission time Handle Problem Language Result Execution time Memory
669748 2022-12-07T08:09:51 Z someone Toy Train (IOI17_train) C++14
11 / 100
243 ms 1784 KB
//#include "train.h"
#include <bits/stdc++.h>
using namespace std;
 
const int N = 1e4 + 42, INF = 1e9;

int n, m, nb[N], nbS[N];
bool isA[N], isR[N], sent[N];
vector<int> adj[N], ans, upd;

void dfs(int i) {
    if(sent[i])
        return;
    sent[i] = true;
    upd.push_back(i);
    for(int j : adj[i]) {
        nbS[j]++;
        if(isA[j] || nbS[j] == nb[j])
            dfs(j);
    }
}
 
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
    n = (int)a.size();
    m = (int)u.size();
    for(int i = 0; i < n; i++)
        isA[i] = (a[i] == 1),
        isR[i] = (r[i] == 1);
    for(int i = 0; i < m; i++) {
        nb[u[i]]++;
        adj[v[i]].push_back(u[i]);
    }
    
    deque<int> id;
    for(int i = 0; i < n; i++)
        if(r[i])
            id.push_back(i);
    int sz = (int)id.size();
    while(true) {
        for(int j : id)
            dfs(j);
        for(int i = 0; i < sz; i++) {
            if((isA[id[0]] && nbS[id[0]] > 0) || (!isA[id[0]] && nbS[id[0]] == nb[id[0]]))
                id.push_back(id[0]);
            id.pop_front();
        }
        for(int j : upd) {
            nbS[j] = 0;
            sent[j] = false;
        }
        upd.clear();
        if(sz == (int)id.size())
            break;
        sz = id.size();
    }
    for(int i : id)
        dfs(i);
    for(int i = 0; i < n; i++)
        ans.push_back(((isA[i] && nbS[i] > 0) || (!isA[i] && nbS[i] == nb[i])));
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1108 KB 3rd lines differ - on the 11th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 1 ms 540 KB 3rd lines differ - on the 12th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 87 ms 1784 KB Output is correct
2 Correct 148 ms 1780 KB Output is correct
3 Correct 199 ms 1768 KB Output is correct
4 Correct 7 ms 1580 KB Output is correct
5 Correct 10 ms 1580 KB Output is correct
6 Correct 7 ms 1452 KB Output is correct
7 Correct 7 ms 1492 KB Output is correct
8 Correct 9 ms 1452 KB Output is correct
9 Correct 6 ms 1428 KB Output is correct
10 Correct 8 ms 1448 KB Output is correct
11 Correct 6 ms 1456 KB Output is correct
12 Correct 6 ms 1256 KB Output is correct
13 Correct 7 ms 1708 KB Output is correct
14 Correct 8 ms 1708 KB Output is correct
15 Correct 7 ms 1620 KB Output is correct
16 Correct 7 ms 1620 KB Output is correct
17 Correct 7 ms 1620 KB Output is correct
18 Correct 243 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1300 KB Output is correct
2 Incorrect 7 ms 1276 KB 3rd lines differ - on the 37th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1512 KB 3rd lines differ - on the 9th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1108 KB 3rd lines differ - on the 11th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -