제출 #846159

#제출 시각아이디문제언어결과실행 시간메모리
846159vjudge1KOVANICE (COI15_kovanice)C++17
0 / 100
416 ms43528 KiB
#include<bits/stdc++.h> #define int long long #define MOD 1000000007 #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; vector<pair<int,int>>v[300005]; int vis[300005],ans[300005]; void dfs(int node,int x){ vis[node]=1; ans[node]=x; for(auto i:v[node]){ if(vis[i.ff])continue; dfs(i.ff,x^i.ss); } return; } int32_t main(){ int n,m,k; cin>>n>>m>>k; for(int i=1;i<=m;i++)ans[i]=-1; vector<pair<int,int>>v2; for(int i=0;i<k;i++){ string s; cin>>s; int a=s[0]-'0'; int b=s[2]-'0'; if(s[1]=='='){ v[a].pb({b,0}); v[b].pb({a,0}); } else{ v[a].pb({b,1}); v[b].pb({a,1}); v2.pb({a,0}); v2.pb({b,1}); } } for(auto i:v2){ if(vis[i.ff])continue; dfs(i.ff,i.ss); } for(int i=1;i<=m;i++){ if(ans[i]==-1)cout<<"?"<<endl; else cout<<"K"<<ans[i]+1<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...