Submission #19720153
Source Code Expand
Copy
#include <bits/stdc++.h> #define pb push_back using namespace std; typedef pair<int,int> pii; const int N=105; const int maxn=1e4+5; int dir[maxn],c[N]; pii edge[maxn]; bool vis[maxn]; vector<pii>G[N]; void dfs(int u) { for(int i=0;i<G[u].size();i++) { pii t=G[u][i]; int e=t.first; if(e<0) e=-e; if(!vis[e]&&c[t.second]==c[u]) { dir[e]=(t.first>0?1:-1); vis[e]=1; dfs(t.second); } } } int main() { int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) { int a,b; scanf("%d%d",&a,&b); edge[i]=make_pair(a,b); G[a].pb(make_pair(i,b)); G[b].pb(make_pair(-i,a)); } for(int i=1;i<=n;i++) scanf("%d",&c[i]); for(int i=1;i<=m;i++) { int a=edge[i].first,b=edge[i].second; if(c[a]!=c[b]) { if(c[a]>c[b]) dir[i]=1;//-> else dir[i]=-1;//<- vis[i]=1; } else { if(!vis[i]) dfs(a); } } for(int i=1;i<=m;i++) printf("%s\n",dir[i]==1?"->":"<-"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Orientation |
User | whix |
Language | C++ (GCC 9.2.1) |
Score | 600 |
Code Size | 1215 Byte |
Status | AC |
Exec Time | 9 ms |
Memory | 4156 KB |
Compile Error
./Main.cpp: In function ‘void dfs(int)’: ./Main.cpp:13:18: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::pair<int, int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare] 13 | for(int i=0;i<G[u].size();i++) | ~^~~~~~~~~~~~ ./Main.cpp: In function ‘int main()’: ./Main.cpp:29:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] 29 | scanf("%d%d",&n,&m); | ~~~~~^~~~~~~~~~~~~~ ./Main.cpp:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] 33 | scanf("%d%d",&a,&b); | ~~~~~^~~~~~~~~~~~~~ ./Main.cpp:39:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] 39 | scanf("%d",&c[i]); | ~~~~~^~~~~~~~~~~~
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_00, example_01, example_02 |
All | cycle_00, cycle_01, cycle_02, cycle_tree_00, cycle_tree_01, cycle_tree_02, example_00, example_01, example_02, many_small_00, many_small_01, many_small_02, many_small_03, many_small_04, many_small_05, many_small_06, many_small_07, many_small_08, many_small_09, many_small_10, many_small_11, many_small_12, many_small_13, many_small_14, many_small_15, many_small_16, many_small_17, many_small_18, many_small_19, max_random_00, max_random_01, max_random_02, max_random_03, max_random_04, max_random_05, max_random_06, max_random_07, max_random_08, max_random_09, perfect_00, perfect_01, perfect_02, small_00, small_01, small_02, small_03, small_04, small_05, small_06, small_07, small_08, small_09 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
cycle_00 | AC | 7 ms | 3616 KB |
cycle_01 | AC | 2 ms | 3660 KB |
cycle_02 | AC | 3 ms | 3660 KB |
cycle_tree_00 | AC | 2 ms | 3640 KB |
cycle_tree_01 | AC | 2 ms | 3512 KB |
cycle_tree_02 | AC | 2 ms | 3516 KB |
example_00 | AC | 2 ms | 3516 KB |
example_01 | AC | 2 ms | 3512 KB |
example_02 | AC | 2 ms | 3652 KB |
many_small_00 | AC | 2 ms | 3520 KB |
many_small_01 | AC | 3 ms | 3512 KB |
many_small_02 | AC | 2 ms | 3516 KB |
many_small_03 | AC | 2 ms | 3652 KB |
many_small_04 | AC | 2 ms | 3508 KB |
many_small_05 | AC | 2 ms | 3532 KB |
many_small_06 | AC | 2 ms | 3532 KB |
many_small_07 | AC | 2 ms | 3672 KB |
many_small_08 | AC | 2 ms | 3532 KB |
many_small_09 | AC | 2 ms | 3512 KB |
many_small_10 | AC | 2 ms | 3532 KB |
many_small_11 | AC | 2 ms | 3696 KB |
many_small_12 | AC | 2 ms | 3532 KB |
many_small_13 | AC | 2 ms | 3640 KB |
many_small_14 | AC | 2 ms | 3652 KB |
many_small_15 | AC | 2 ms | 3668 KB |
many_small_16 | AC | 2 ms | 3640 KB |
many_small_17 | AC | 2 ms | 3696 KB |
many_small_18 | AC | 2 ms | 3652 KB |
many_small_19 | AC | 2 ms | 3656 KB |
max_random_00 | AC | 2 ms | 3556 KB |
max_random_01 | AC | 2 ms | 3740 KB |
max_random_02 | AC | 3 ms | 3608 KB |
max_random_03 | AC | 2 ms | 3568 KB |
max_random_04 | AC | 2 ms | 3612 KB |
max_random_05 | AC | 2 ms | 3720 KB |
max_random_06 | AC | 3 ms | 3632 KB |
max_random_07 | AC | 2 ms | 3736 KB |
max_random_08 | AC | 3 ms | 3556 KB |
max_random_09 | AC | 6 ms | 3700 KB |
perfect_00 | AC | 7 ms | 4148 KB |
perfect_01 | AC | 9 ms | 4156 KB |
perfect_02 | AC | 7 ms | 4004 KB |
small_00 | AC | 2 ms | 3512 KB |
small_01 | AC | 2 ms | 3516 KB |
small_02 | AC | 2 ms | 3632 KB |
small_03 | AC | 3 ms | 3500 KB |
small_04 | AC | 3 ms | 3652 KB |
small_05 | AC | 2 ms | 3628 KB |
small_06 | AC | 2 ms | 3648 KB |
small_07 | AC | 2 ms | 3688 KB |
small_08 | AC | 3 ms | 3508 KB |
small_09 | AC | 3 ms | 3640 KB |