# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1120913 | vjudge1 | KOVANICE (COI15_kovanice) | C++17 | 49 ms | 41820 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(30001);
ll a[30001];
void upd(ll x)
{
while(!(ve[x].empty()))
{
ll z=ve[x].front();
ve[x].pop();
if(a[z]==-1)
{
a[z]=a[x];
upd(z);
}
}
}
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;
upd(x);
upd(y);
}
else
{
if(a[x]!=-1)
a[y]=a[x];
else if(a[y]!=-1)
a[x]=a[y];
else
{
ve[x].push(y);
ve[y].push(x);
}
}
}
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... |