답안 #416587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
416587 2021-06-02T16:25:57 Z yanire 장난감 기차 (IOI17_train) C++11
0 / 100
11 ms 1868 KB
#include <bits/stdc++.h>
using namespace std;
#include "train.h"
#define fin(i,s,n) for(auto i = s; i < n; ++i)
#define fine(i,s,n) for(auto i = s; i <= n; ++i)
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define all(x) (x).begin(),(x).end()
#define chkmin(a,b) a = min(a,b)
#define chkmax(a,b) a = max(a,b)
using stdvec = vector<int>;
using ii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vii = vector<ii>;
#define sz(a) int((a).size())
const int maxn = 5005;
vi G[maxn],T[maxn],g[maxn];
bool vis[maxn];
int id[maxn],c[maxn],p[maxn];
vi lst;
void dfs(int u) {
    if(vis[u]) return;
    vis[u] = 1;
    for(int v : G[u]) dfs(v);
    lst.pb(u);
}
void mark(int u, int cid) {
    if(!vis[u]) return;
    vis[u] = 0,id[u] = cid;
    for(int v : T[u]) mark(v,cid);
}
vi who_wins(vi a, vi r, vi u, vi v) {
    int n = a.size(),m = u.size();
    fin(i,0,m) G[u[i]].pb(v[i]),T[v[i]].pb(u[i]);
    fin(i,0,n) p[i] = a[i];
    lst.clear();
    fin(i,0,n) dfs(i);
    int lid = 0;
    reverse(all(lst));
    fin(i,0,n) if(vis[lst[i]]) mark(lst[i],lid++);
    fin(i,0,n) c[id[i]] |= r[i];
    vi deg(n,0);
    fin(i,0,m) if(id[u[i]]!=id[v[i]]) g[id[v[i]]].pb(id[u[i]]),++deg[id[u[i]]];
    queue<int> q;
    fin(i,0,n) if(!deg[i]) q.push(i);
    while(!q.empty()) {
        int cu = q.front();
        q.pop();
        for(int nv : g[cu]) {
            c[nv] |= c[cu];
            if(--deg[nv]==0) q.push(nv);
        }
    }
    vi res(n);
    fin(i,0,n) res[i] = c[id[i]];
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1612 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 588 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1868 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1484 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 1612 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1612 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -