This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O2,O3,Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,popcnt,lzcnt,abm,mmx,avx,avx2,fma,bmi,bmi2")
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;
int main(){
fast;
vector<pair<ll,ll>>v;
ll n,m,k,a,b;
char c;
vector<ll>cvb(m, 0);
cin>>n>>m>>k;
for(ll i=0;i<k;i++){
cin>>a>>c>>b;
if(c=='='){
v.push_back({a,b});
}
else if(c=='<'){
cvb[a]=1;
cvb[b]=2;
}
else{
cvb[a]=2;
cvb[b]=1;
}
}
for(ll j=0;j<100;j++){
for(ll i=0;i<v.size();i++){
a=v[i].first,b=v[i].second;
if(cvb[a]!=cvb[b] and cvb[a]!=0 and cvb[b]!=0){
cvb[a]=0;
cvb[b]=0;
}
else if(cvb[a]!=cvb[b] and cvb[a]==0){
cvb[a]=cvb[b];
}
else if(cvb[a]!=cvb[b]){
cvb[b]=cvb[a];
}
}
}
for(ll i=1;i<=m;i++){
if(cvb[i]==0) cout<<'?'<<endl;
else cout<<'K'<<cvb[i]<<endl;
}
}
Compilation message (stderr)
kovanice.cpp: In function 'int main()':
kovanice.cpp:29:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(ll i=0;i<v.size();i++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |