답안 #418936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
418936 2021-06-06T08:56:39 Z SlavicG 장난감 기차 (IOI17_train) C++17
0 / 100
9 ms 1496 KB
#include "train.h";
#include "bits/stdc++.h"
 
using namespace std;
 
#define ll long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()
#define         fastio               ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define      GR(a,n,m)               vector<vector<int>> a(n, vector<int>(m, 0));
const int N = 5005;
int n;
bool vis[N];
vector<int> adj[N], rev[N], a;

vector<int> F(vector<int> f, int p){

     for(auto x: f){
        vis[x] = true;
    }

    vector<int> ret;
    vector<int> deg(n, 0);
    for(int i = 0;i < n;i++){
        for(auto x: adj[i]){
            if(!vis[x])++deg[x];
        }
    }

    while(sz(f) > 0)
    {
        int u = f.back();
        ret.pb(u);
        f.pop_back();

        for(auto v: rev[u]){
            if(!vis[v]){
                --deg[v];
                if(a[v] == p || !deg[v]){
                    vis[v] = true;
                    f.pb(v);
                }
            }
        }
    }
    return ret;
}

vector<int> who_wins(vector<int> tempa, vector<int> r, vector<int> u, vector<int> v){
    n = sz(tempa);
    int M = sz(u);
    a = tempa;

    for(int i = 0;i < M;i++){
        adj[u[i]].pb(v[i]);
        rev[v[i]].pb(u[i]);
    }

    vector<int> ans(n, 0);

    while(true)
    {
        vector<int> rm, c, fA;
        bool finished = true;
        for(int i = 0;i < n;i++){
            if(vis[i])continue;
            if(r[i])c.pb(i);
            if(!r[i])finished = false;
            rm.pb(i);
        }

        fA = F(c, 1);

        if(!finished){
            for(auto x: rm)ans[x] = 1;
            break;
        }

        vector<int> s, fAA(n, 0);

        for(auto x: fA)fAA[x] = 1;

        for(auto x: rm){
            vis[x] = false;
            if(!fAA[x])s.pb(x);
        }
        vector<int> fB = F(s, 0);
        if(sz(fB) == sz(rm))break;
    }
    return ans;
}
/*
void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int> aa(n), rr(n), uu(m), vv(m);
    forn(i,n)cin>>aa[i];
    forn(i,n)cin>>rr[i];
    forn(i,m)cin>>uu[i];
    forn(i,m)cin>>vv[i];

    vector<int> rasp = who_wins(aa,rr,uu,vv);
    for(auto x: rasp)cout << x << " ";
}
 
int32_t main()
{
    fastio;
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
}
*/

Compilation message

train.cpp:1:19: warning: extra tokens at end of #include directive
    1 | #include "train.h";
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1100 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 460 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1496 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1356 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1368 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1100 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -