Submission #413033

# Submission time Handle Problem Language Result Execution time Memory
413033 2021-05-28T06:18:31 Z 조영욱(#7624) Toy Train (IOI17_train) C++14
0 / 100
10 ms 1228 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> adj[5000];
int deg[5000];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
    int n=a.size();
    int m=u.size();
    for(int i=0;i<m;i++) {
        if (r[u[i]]==0&&r[v[i]]==0) {
            adj[u[i]].push_back(v[i]);
            deg[v[i]]++;
        }
    }
    queue<int> q;
    for(int i=0;i<n;i++) {
        if (deg[i]==0) {
            q.push(i);
        }
    }
    int cnt=0;
    while (!q.empty()) {
        int now=q.front();
        q.pop();
        cnt++;
        for(int i=0;i<adj[now].size();i++) {
            int nt=adj[now][i];
            deg[nt]--;
            if (deg[nt]==0) {
                q.push(nt);
            }
        }
    }
    vector<int> ret;
    for(int i=0;i<n;i++) {
        ret.push_back(cnt==n);
    }
    return ret;
}

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:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int i=0;i<adj[now].size();i++) {
      |                     ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 716 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 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 10 ms 992 KB Output is correct
2 Correct 8 ms 1196 KB Output is correct
3 Correct 7 ms 1228 KB Output is correct
4 Incorrect 7 ms 1132 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 6 ms 692 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 8 ms 1088 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 4 ms 716 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -