# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
964231 | LucaIlie | Stray Cat (JOI20_stray) | C++17 | 0 ms | 0 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 "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e4;
const int MAX_M = 2e4;
bool vis[MAX_N], visE[MAX_M];
int d[MAX_N];
vector<int> adj[MAX_N];
vector<int> Mark( int N, int M, int A, int B, vector<int> U, vector<int> V ) {
vector<int> X( M );
for ( int i = 0; i < M; i++ ) {
adj[U[i]].push_back( i );
adj[V[i]].push_back( i );
}
queue<int> q;
d[0] = 0;
vis[0] = true;
q.push( 0 );
while ( !q.empty() ) {
int u = q.front();
q.pop();
for ( int e: adj[u] ) {
if ( visE[e] )
continue;
visE[e] = true;
int v = (U[e] == u ? V[e] : U[e]);
X[e] = d[u];
if ( vis[v] )
continue;
d[v] = (d[u] + 1) % 3;
vis[v] = true;
q.push( v );
}
}
return X;
}