# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1068490 | 2024-08-21T10:12:37 Z | Abito | 장난감 기차 (IOI17_train) | C++17 | 661 ms | 1372 KB |
#include "train.h" #include <bits/stdc++.h> //#define int long long #define pb push_back using namespace std; const int N=5005; int n; bool a[N],c[N],cyc[N],vis[N]; vector<int> adj[N]; bool checkcyc(int s){ queue<int> q; q.push(s); vis[s]=1; bool ok=0; while (!q.empty()){ int x=q.front(); //cout<<x<<' '; q.pop(); for (auto u:adj[x]){ if (c[u]) continue; if (vis[u]) ok=1; else{ vis[u]=1; q.push(u); } } }//cout<<endl; return ok; } bool getans(int s){ queue<int> q; q.push(s); vis[s]=1; bool ok=0; while (!q.empty()){ int x=q.front(); //cout<<x<<' '; q.pop(); ok|=cyc[x]; for (auto u:adj[x]){ if (vis[u]) continue; else{ vis[u]=1; q.push(u); } } }//cout<<endl; return ok; } std::vector<int32_t> who_wins(std::vector<int32_t> A, std::vector<int32_t> r, std::vector<int32_t> u, std::vector<int32_t> v) { n=A.size(); for (int i=1;i<=n;i++) a[i]=A[i-1],c[i]=r[i-1]; for (int i=0;i<u.size();i++){ adj[u[i]+1].pb(v[i]+1); } vector<int> ans(n); for (int i=1;i<=n;i++){ if (c[i]) continue; cyc[i]=checkcyc(i); memset(vis,0,sizeof(vis)); } for (int i=1;i<=n;i++){ if (!c[i]){ ans[i-1]=!cyc[i]; continue; } ans[i-1]=!getans(i); memset(vis,0,sizeof(vis)); } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 61 ms | 908 KB | 3rd lines differ - on the 3rd token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | 3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 1116 KB | Output is correct |
2 | Correct | 30 ms | 1372 KB | Output is correct |
3 | Correct | 30 ms | 1372 KB | Output is correct |
4 | Incorrect | 608 ms | 1368 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 499 ms | 1048 KB | 3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 661 ms | 1364 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 61 ms | 908 KB | 3rd lines differ - on the 3rd token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |