Submission #1120769

#TimeUsernameProblemLanguageResultExecution timeMemory
1120769vjudge1KOVANICE (COI15_kovanice)C++14
0 / 100
688 ms30052 KiB
//#pragma GCC optimize ("O1") #include <bits/stdc++.h> using namespace std; #define endl '\n' #define pb push_back #define F first #define S second #define ll long long //#define int ll #define pii pair<int, int> #define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define M_PI 3.14159265358979323846 #define all(v) v.begin(), v.end() #define pss pair<string, string> #define no cout<<"NO"<<endl; #define yes cout<<"YES"<<endl; #define imp cout<<-1<<endl; #define flu cout.flush(); #define Endl endl const int N = 100009; const int mod = 1e9+7; map<int, int>ans; map<int, int>par; void solve(){ int n, m, q; cin>>n>>m>>q; int yx=0; for(int i=1; i<=m; i++){ par[i]=i; } vector<pii>l; for(int i=0; i<q; i++){ string s; cin>>s; int e1=0, e2=0, fi=0; char sym; int n=s.size(); for(int i=0; i<n; i++){ if(s[i]=='<' or s[i]=='>' or s[i]=='='){ sym=s[i]; fi++; continue; } if(fi==0){ e1=e1*10+(int(s[i])-48); } else{ e2=e2*10+(int(s[i])-48); } } if(sym!='='){ if(sym=='>'){ swap(e1, e2); } ans[e1]=1; ans[e2]=2; yx++; } if(sym=='='){ l.pb({e1, e2}); l.pb({e2, e1}); } } for(pii i : l){ int e1=i.F, e2=i.S; int ce1=e1; while(par[e1]!=e1){ if(ans[par[e1]]==0){ ans[par[e1]]=max(ans[e1], ans[e2]); } e1=par[e1]; } int ce2=e2; par[ce1]=e1; par[ce2]=e1; } if(yx==0){ for(int i=0; i<m; i++){ cout<<"?"<<endl; } return; } for(int i=1; i<=m; i++){ if(ans[par[i]]==1){ cout<<"K1"<<endl; } else if(ans[par[i]]==2){ cout<<"K2"<<endl; } else{ //cout<<ans[par[i]]<<" "; cout<<"?"<<endl; } } } signed main(){ io; int t=1; //cin>>t; while(t--){ solve(); } }

Compilation message (stderr)

kovanice.cpp: In function 'void solve()':
kovanice.cpp:57:13: warning: 'sym' may be used uninitialized in this function [-Wmaybe-uninitialized]
   57 |             if(sym=='>'){
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...