# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
585289 | 2022-06-28T14:40:37 Z | hibiki | One-Way Streets (CEOI17_oneway) | C++11 | 2 ms | 2644 KB |
#include<bits/stdc++.h> using namespace std; #define pb push_back #define f first #define s second #define sz(x) (int)x.size() #define all(x) x.begin(),x.end() int n,m,p; int l[100005], r[100005], cnt[100005], ask[100005], ans[100005]; vector<int> v[100005]; bool reach[100005], reach2[100005]; void dfs(int nw, int fa) { reach[nw] = true; for(auto idx: v[nw]) { int go = nw ^ l[idx] ^ r[idx]; if(go == fa) continue; if(reach[go] && ans[idx] != 3)ans[idx] = 3, cnt[go]--, cnt[nw]++; else if(!reach[go]) dfs(go, nw); } } void dfs2(int nw, int fa) { reach2[nw] = true; for(auto idx: v[nw]) { int go = nw ^ l[idx] ^ r[idx]; if(go == fa || reach2[go]) continue; dfs2(go, nw); if(cnt[go] > 0 || ask[go] == 0) ans[idx] = 3; else if(ask[go] > 0) { if(l[idx] ^ nw) ans[idx] = 2; else ans[idx] = 1; } else if(ask[go] < 0) { if(l[idx] ^ nw) ans[idx] = 1; else ans[idx] = 2; } ask[nw] += ask[go]; cnt[nw] += cnt[go]; } } int main() { scanf("%d %d",&n,&m); for(int i = 0; i < m; i++) { scanf("%d %d",&l[i],&r[i]); v[l[i]].pb(i); v[r[i]].pb(i); } for(int i = 1; i <= n; i++) if(!reach[i]) dfs(i, -1); scanf("%d",&p); while(p--) { int a,b; scanf("%d %d",&a,&b); ask[a]++; ask[b]--; } for(int i = 1; i <= n; i++) if(!reach2[i]) dfs2(i, -1); char wd[] = {'0', 'L', 'R', 'B'}; for(int i = 0; i < m; i++) printf("%c",wd[ans[i]]); printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
3 | Correct | 2 ms | 2644 KB | Output is correct |
4 | Correct | 2 ms | 2644 KB | Output is correct |
5 | Correct | 2 ms | 2644 KB | Output is correct |
6 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
3 | Correct | 2 ms | 2644 KB | Output is correct |
4 | Correct | 2 ms | 2644 KB | Output is correct |
5 | Correct | 2 ms | 2644 KB | Output is correct |
6 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
3 | Correct | 2 ms | 2644 KB | Output is correct |
4 | Correct | 2 ms | 2644 KB | Output is correct |
5 | Correct | 2 ms | 2644 KB | Output is correct |
6 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |