# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
343337 | 2021-01-03T17:36:12 Z | benedict0724 | One-Way Streets (CEOI17_oneway) | C++17 | 11 ms | 640 KB |
#include <bits/stdc++.h> using namespace std; vector<int> adj[1002]; pair<int, int> road[1002]; pair<int, int> haveTo[1002]; int subOf[1002]; bool visited[1002]; bool poss = false; void dfs(int x, int s, int e){ visited[x] = true; if(x == e){ poss = true; return; } subOf[x] = 1; for(auto u : adj[x]){ if(!visited[u] && (x != s || u != e)){ dfs(u, s, e); } if(poss) return; } } int main() { int n, m; scanf("%d %d", &n, &m); for(int i=1;i<=m;i++){ int s, e; scanf("%d %d", &s, &e); adj[s].push_back(e); adj[e].push_back(s); road[i] = {s, e}; } int p; scanf("%d", &p); for(int i=1;i<=p;i++){ int s, e; scanf("%d %d", &s, &e); haveTo[i] = {s, e}; } for(int i=1;i<=m;i++){ int s = road[i].first, e = road[i].second; bool toL = true, toR = true; fill(visited, visited + 1002, false); fill(subOf, subOf + 1002, 0); poss = false; int cnt = 0; for(auto u : adj[s]){ if(u == e) cnt++; } if(cnt > 1){ printf("B"); continue; } dfs(s, s, e); if(poss){ printf("B"); } else{ for(int j=1;j<=p;j++){ if(subOf[haveTo[j].first] == 1 && subOf[haveTo[j].second] == 0){ toL = false; } if(subOf[haveTo[j].first] == 0 && subOf[haveTo[j].second] == 1){ toR = false; } } if(toL && toR) printf("B"); else if(toL) printf("L"); else printf("R"); } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 9 ms | 364 KB | Output is correct |
4 | Correct | 10 ms | 364 KB | Output is correct |
5 | Correct | 10 ms | 364 KB | Output is correct |
6 | Correct | 2 ms | 364 KB | Output is correct |
7 | Correct | 11 ms | 364 KB | Output is correct |
8 | Correct | 10 ms | 364 KB | Output is correct |
9 | Correct | 7 ms | 640 KB | Output is correct |
10 | Correct | 4 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 9 ms | 364 KB | Output is correct |
4 | Correct | 10 ms | 364 KB | Output is correct |
5 | Correct | 10 ms | 364 KB | Output is correct |
6 | Correct | 2 ms | 364 KB | Output is correct |
7 | Correct | 11 ms | 364 KB | Output is correct |
8 | Correct | 10 ms | 364 KB | Output is correct |
9 | Correct | 7 ms | 640 KB | Output is correct |
10 | Correct | 4 ms | 364 KB | Output is correct |
11 | Runtime error | 1 ms | 492 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 9 ms | 364 KB | Output is correct |
4 | Correct | 10 ms | 364 KB | Output is correct |
5 | Correct | 10 ms | 364 KB | Output is correct |
6 | Correct | 2 ms | 364 KB | Output is correct |
7 | Correct | 11 ms | 364 KB | Output is correct |
8 | Correct | 10 ms | 364 KB | Output is correct |
9 | Correct | 7 ms | 640 KB | Output is correct |
10 | Correct | 4 ms | 364 KB | Output is correct |
11 | Runtime error | 1 ms | 492 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
12 | Halted | 0 ms | 0 KB | - |