# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1120580 | vjudge1 | KOVANICE (COI15_kovanice) | C++17 | 499 ms | 5312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int sz=2e6+5;
const int INF=1e18;
const int MOD=1e9+7;
int arr[sz],res[sz];
void solve()
{
vector<pair<int,int>> equalities;
int n,m,v;
cin>>n>>m>>v;
for(int i=0;i<v;i++)
{
int a,b;
char c;
cin>>a>>c>>b;
if(c=='=')
equalities.push_back({a,b});
else
{
if(c=='<')
{
res[a]=1;
res[b]=2;
}
else
{
res[a]=2;
res[b]=1;
}
}
}
for(int l=0;l<100;l++)
{
for(int i=0;i<equalities.size();i++)
{
int a=equalities[i].first;
int b=equalities[i].second;
if(res[a]!=res[b])
{
if(res[a]!=0 && res[b]!=0)
{
res[a]=0;
res[b]=0;
}
else if(res[a]==0)
res[a]=res[b];
else
res[b]=res[a];
}
}
}
for(int i=1;i<=m;i++)
{
if(res[i]==0)
cout<<'?'<<endl;
else
cout<<'K'<<res[i]<<endl;
}
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
}
Compilation message (stderr)
# | 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... |