답안 #1054919

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1054919 2024-08-12T13:03:04 Z Wansur 장난감 기차 (IOI17_train) C++17
23 / 100
2000 ms 1880 KB
#include <bits/stdc++.h>
#include "train.h"
#define ent '\n'
#define  f first
#define s second
//#define int long long

using namespace std;
typedef long long ll;
const int maxn = 5e3 + 12;
const int mod = 1e9 + 7;

vector<int> g[maxn], rg[maxn];
bool won[maxn], del[maxn];
int out[maxn];
int n, m;

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> U, vector<int> V){
    n = a.size(), m = U.size();
    vector<int> ans(n);

    function<bool(int)> check = [&](int v){
        for(int i=0;i<n;i++){
            won[i] = out[i] = 0;
            g[i].clear();
            rg[i].clear();
        }

        for(int i=0;i<m;i++){
            if(del[U[i]] || del[V[i]]){
                continue;
            }
            out[U[i]]++;
            g[U[i]].push_back(V[i]);
            rg[V[i]].push_back(U[i]);
        }

        queue<int> q;
        won[v] = 1;
        q.push(v);
        while(q.size()){
            int v = q.front();
            q.pop();
            for(int to:rg[v]){
                if(a[to] == 1 && !won[to]){
                    won[to] = 1;
                    q.push(to);
                }
                if(a[to] == 0){
                    out[to]--;
                    if(!out[to]){
                        won[to] = 1;
                        q.push(to);
                    }
                }
            }
        }

        bool ok = 0;

        for(int to:g[v]){
            ok |= won[to];
        }

        if(ok){
            for(int i=0;i<n;i++){
                if(won[i]){
                    ans[i] = 1;
                    del[i] = 1;
                }
            }
            return 1;
        }

        return 0;
    };

    while(1){
        bool ok = 0;
        for(int i=0;i<n;i++){
            if(r[i] == 1 && !del[i] && check(i)){
                ok = 1;
                break;
            }
        }
        if(!ok) break;
    }

    return ans;
}

Compilation message

train.cpp: In lambda function:
train.cpp:24:29: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   24 |             won[i] = out[i] = 0;
      |                      ~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2008 ms 1116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 604 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 1568 KB Output is correct
2 Correct 178 ms 1624 KB Output is correct
3 Correct 279 ms 1624 KB Output is correct
4 Correct 7 ms 1880 KB Output is correct
5 Correct 26 ms 1628 KB Output is correct
6 Correct 198 ms 1628 KB Output is correct
7 Correct 5 ms 1628 KB Output is correct
8 Correct 7 ms 1732 KB Output is correct
9 Correct 4 ms 1628 KB Output is correct
10 Correct 7 ms 1628 KB Output is correct
11 Correct 4 ms 1628 KB Output is correct
12 Correct 5 ms 1628 KB Output is correct
13 Correct 4 ms 1628 KB Output is correct
14 Correct 7 ms 1628 KB Output is correct
15 Correct 7 ms 1624 KB Output is correct
16 Correct 8 ms 1628 KB Output is correct
17 Correct 4 ms 1628 KB Output is correct
18 Correct 333 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2041 ms 1368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 4 ms 1628 KB Output is correct
3 Correct 5 ms 1628 KB Output is correct
4 Correct 5 ms 1624 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 4 ms 1116 KB Output is correct
7 Correct 5 ms 1372 KB Output is correct
8 Correct 4 ms 1372 KB Output is correct
9 Correct 3 ms 1372 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 4 ms 1168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2008 ms 1116 KB Time limit exceeded
2 Halted 0 ms 0 KB -