Submission #1120918

#TimeUsernameProblemLanguageResultExecution timeMemory
1120918vjudge1KOVANICE (COI15_kovanice)C++17
10 / 100
50 ms41812 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(30001); ll a[30001]; void upd(ll x) { while(!(ve[x].empty())) { ll z=ve[x].front(); ve[x].pop(); if(a[z]==-1) { a[z]=a[x]; upd(z); } } } 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; upd(x); upd(y); } else { if(a[x]!=-1) a[y]=a[x]; else if(a[y]!=-1) a[x]=a[y]; else { ve[x].push(y); ve[y].push(x); } } } for(i=0;i<m;i++) upd(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:23:16: warning: unused variable 'j' [-Wunused-variable]
   23 |     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...