Submission #287149

# Submission time Handle Problem Language Result Execution time Memory
287149 2020-08-31T12:45:02 Z peti1234 Toy Train (IOI17_train) C++17
12 / 100
436 ms 1792 KB
#include <bits/stdc++.h>

using namespace std;
const int c=5002;
int n, m, v[c], db[c], si[c];
bool sol[c];
vector<int> sz[c], inv[c], ans;
queue<int> q;
vector<int> who_wins(vector<int> ki, vector<int> t, vector<int> x, vector<int> y) {
    n=ki.size(), m=x.size();
    for (int i=0; i<m; i++) {
        int a=x[i], b=y[i];
        sz[a].push_back(b), inv[b].push_back(a);
    }
    for (int i=0; i<n; i++) si[i]=sz[i].size();
    for (int i=0; i<n; i++) {
        if (t[i]) {
            v[i]=-1;
            q.push(i);
            while(q.size()>0) {
                int id=q.front();
                q.pop();
                if (v[id]!=1) {
                    v[id]++;
                    for (int i=0; i<inv[id].size(); i++) {
                        int x=inv[id][i];
                        db[x]++;
                        if (!v[x] && (db[x]==si[x] || (db[x]==1 && ki[x]))) q.push(x);
                    }
                }
            }
            if (v[i]) for (int j=0; j<n; j++) sol[j]^=v[j];
            for (int j=0; j<n; j++) v[j]=0, db[j]=0;
        }
    }
    for (int i=0; i<n; i++) ans.push_back(sol[i]);
    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:25:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |                     for (int i=0; i<inv[id].size(); i++) {
      |                                   ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1280 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 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 78 ms 1784 KB Output is correct
2 Correct 133 ms 1784 KB Output is correct
3 Correct 177 ms 1784 KB Output is correct
4 Incorrect 436 ms 1784 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 32 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 10 ms 1664 KB Output is correct
2 Correct 11 ms 1664 KB Output is correct
3 Correct 11 ms 1792 KB Output is correct
4 Correct 9 ms 1664 KB Output is correct
5 Correct 1 ms 640 KB Output is correct
6 Correct 5 ms 1280 KB Output is correct
7 Correct 7 ms 1280 KB Output is correct
8 Correct 7 ms 1280 KB Output is correct
9 Correct 7 ms 1280 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 6 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1280 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -