답안 #287156

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
287156 2020-08-31T12:50:59 Z peti1234 장난감 기차 (IOI17_train) C++17
23 / 100
454 ms 1792 KB
#include <bits/stdc++.h>

using namespace std;
const int c=5002;
int n, m, v[c], db[c], si[c];
bool ki[c], sol[c];
vector<int> sz[c], inv[c], ans;
queue<int> q;
void solve() {
    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);
            }
        }
    }
}
vector<int> who_wins(vector<int> f, vector<int> t, vector<int> x, vector<int> y) {
    n=f.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(), ki[i]=f[i];
    for (int i=0; i<n; i++) {
        if (t[i]) {
            v[i]=-1;
            q.push(i);
            solve();
            if (v[i]) sol[i]=1;
            for (int j=0; j<n; j++) v[j]=0, db[j]=0;
        }
    }
    for (int i=0; i<n; i++) {
        if (sol[i]) q.push(i);
    }
    solve();
    for (int i=0; i<n; i++) ans.push_back(v[i]);
    return ans;
}

Compilation message

train.cpp: In function 'void solve()':
train.cpp:15:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |             for (int i=0; i<inv[id].size(); i++) {
      |                           ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 1152 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 1660 KB Output is correct
2 Correct 131 ms 1528 KB Output is correct
3 Correct 172 ms 1528 KB Output is correct
4 Correct 423 ms 1476 KB Output is correct
5 Correct 95 ms 1664 KB Output is correct
6 Correct 24 ms 1664 KB Output is correct
7 Correct 454 ms 1680 KB Output is correct
8 Correct 10 ms 1768 KB Output is correct
9 Correct 9 ms 1664 KB Output is correct
10 Correct 12 ms 1664 KB Output is correct
11 Correct 10 ms 1664 KB Output is correct
12 Correct 9 ms 1664 KB Output is correct
13 Correct 11 ms 1700 KB Output is correct
14 Correct 11 ms 1664 KB Output is correct
15 Correct 11 ms 1664 KB Output is correct
16 Correct 11 ms 1664 KB Output is correct
17 Correct 11 ms 1792 KB Output is correct
18 Correct 234 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 1280 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1536 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 11 ms 1536 KB Output is correct
4 Correct 14 ms 1408 KB Output is correct
5 Correct 1 ms 640 KB Output is correct
6 Correct 5 ms 1152 KB Output is correct
7 Correct 6 ms 1152 KB Output is correct
8 Correct 7 ms 1152 KB Output is correct
9 Correct 6 ms 1152 KB Output is correct
10 Correct 2 ms 896 KB Output is correct
11 Correct 6 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 1152 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -