Submission #1121009

#TimeUsernameProblemLanguageResultExecution timeMemory
1121009MoonnKOVANICE (COI15_kovanice)C++17
0 / 100
432 ms207716 KiB
#include <bits/stdc++.h> #define ll long long #define endl "\n"; #define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; vector<queue<ll>>ve(300001); ll a[300001],ch[300001]; void dfs(ll x) { ch[x]=1; while(!ve[x].empty()) { if(a[x]!=-1) a[ve[x].front()]=a[x]; if(ch[ve[x].front()]!=1) dfs(ve[x].front()); if(a[x]==-1) a[x]=a[ve[x].front()]; ve[x].pop(); } } int main() { ll n,m,v,i,j; cin>>n>>m>>v; for(i=0;i<m;i++) a[i]=-1; ll x,y; char d; queue<ll>qq; for(i=0;i<v;i++) { cin>>x>>d>>y; x--; y--; if(d=='<') { a[x]=1; a[y]=2; } else { ve[x].push(y); ve[y].push(x); } } if(n==1) { for(i=0;i<m;i++) cout<<"K1\n"; return 0; } for(i=0;i<m;i++) { if(ch[i]==0) dfs(i); } for(i=0;i<m;i++) { if(a[i]==-1) cout<<"?\n"; else cout<<"K"<<a[i]<<endl; } }

Compilation message (stderr)

kovanice.cpp: In function 'int main()':
kovanice.cpp:24:16: warning: unused variable 'j' [-Wunused-variable]
   24 |     ll n,m,v,i,j;
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...