# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1120994 | Moonn | KOVANICE (COI15_kovanice) | C++17 | 420 ms | 207752 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>
#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(300001);
ll a[300001],ch[300001];
void dfs(ll x)
{
ch[x]=1;
while(!ve[x].empty())
{
if(a[x]!=-1)
a[ve[x].front()]=a[x];
if(ch[ve[x].front()]!=1)
dfs(ve[x].front());
if(a[x]==-1)
a[x]=a[ve[x].front()];
ve[x].pop();
}
}
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;
}
else
{
ve[x].push(y);
ve[y].push(x);
}
}
for(i=0;i<m;i++)
{
if(ch[i]==0)
dfs(i);
}
for(i=0;i<m;i++)
{
if(a[i]==-1)
cout<<"?\n";
else
cout<<"K"<<a[i]<<endl;
}
}
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... |