# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
296862 | 2020-09-11T02:20:57 Z | DanerZein | 장난감 기차 (IOI17_train) | C++14 | 180 ms | 262148 KB |
#include "train.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; vector<vi> G; bitset<5010> ab,cs,cl; int vis[5010]; vi res,path; int n; bool dfs(int u){ vis[u]=1; if(ab[u] and cs[u] and cl[u]){ return res[u]=1; } if(!ab[u] and !cs[u] and cl[u]){ return res[u]=0; } bool ans=0; for(auto &v:G[u]){ ans=dfs(v); } if(G[u].size()==0){ if(ab[u] and !cs[u]){ ans=0; } if(!ab[u] and cs[u]){ ans=1; } } return res[u]=ans; } bool ciclo(int u,bool ch){ vis[u]=1; //bool sw=0; if(cs[u]) ch=1; for(auto &v:G[u]){ if(vis[v]==1 and ch){ return 1; } if(vis[v]==-1){ ch|=ciclo(v,ch); } } return res[u]=ch; } void arezou(){ for(int i=0;i<n;i++){ if(vis[i]==-1){ res[i]=ciclo(i,0); /*for(int i=0;i<n;i++){ cout<<vis[i]<<" "; } cout<<endl;*/ } } } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { bool tw=0; n=a.size(); for(int i=0;i<a.size();i++){ if(a[i]==0) tw=1; ab[i]=a[i]; cs[i]=r[i]; } G.resize(n+1); res.resize(n); for(int i=0;i<u.size();i++){ int x=u[i],y=v[i]; if(x!=y) G[x].push_back(y); if(x==y and tw==1) cl[x]=1; } memset(vis,-1,sizeof vis); if(tw==1){ for(int i=0;i<n;i++){ if(vis[i]==-1){ res[i]=dfs(i); } } } else{ arezou(); } return res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 928 KB | Output is correct |
2 | Correct | 5 ms | 896 KB | Output is correct |
3 | Correct | 5 ms | 896 KB | Output is correct |
4 | Correct | 5 ms | 896 KB | Output is correct |
5 | Correct | 4 ms | 896 KB | Output is correct |
6 | Correct | 4 ms | 1024 KB | Output is correct |
7 | Correct | 4 ms | 896 KB | Output is correct |
8 | Incorrect | 4 ms | 896 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 177 ms | 262148 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1408 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 178 ms | 262148 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 180 ms | 262148 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 928 KB | Output is correct |
2 | Correct | 5 ms | 896 KB | Output is correct |
3 | Correct | 5 ms | 896 KB | Output is correct |
4 | Correct | 5 ms | 896 KB | Output is correct |
5 | Correct | 4 ms | 896 KB | Output is correct |
6 | Correct | 4 ms | 1024 KB | Output is correct |
7 | Correct | 4 ms | 896 KB | Output is correct |
8 | Incorrect | 4 ms | 896 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
9 | Halted | 0 ms | 0 KB | - |