# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829924 | Rifal | Stray Cat (JOI20_stray) | C++14 | 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<bits/stdc++.h>
#include "Anthony.h"
#include <vector>
using namespace std;
s
namespace {
const int Max = 2e4 + 5;
vector<int> v[Max];
int level[Max];
void bfs(int s) {
queue<int> q;
q.push(s); level[s] = 1;
while(!q.empty()) {
int fron = q.front(); q.pop();
for(auto i : v[fron]) {
if(level[i] == 0) {
level[i] = level[fron] + 1;
q.push(i);
}
else if(level[i] > level[fron]+1){
level[i] = level[fron] + 1;
q.push(i);
}
}
}
}
}
vector<int> Mark(int N, int M, int A, int B,
vector<int> U, vector<int> V) {
vector<int> x;
for(int i = 0; i < M; i++) {
v[U[i]].push_back(V[i]);
v[V[i]].push_back(U[i]);
}
bfs(0);
for(int i = 0; i < M; i++) {
int a = min(level[U[i]]%3,level[V[i]]%3), b = max(level[U[i]]%3,level[V[i]]%3);
if(a == 1 && b == 2) x.push_back(1);
else if(a == 0 && b == 2) x.push_back(2);
else if(a == 0 && b == 1) x.push_back(0);
else if(a == b) x.push_back(a);
}
return x;
}
#include "Catherine.h"
#include <vector>
using namespace std;
namespace {
int A, B;
int variable_example = 0;
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
}
int Move(vector<int> y) {
++variable_example; int a = 10, b = -1;
for (int i = 0; i < A; ++i) {
if(y[i] != 0) {
a = min(a,i);
b = max(b,i);
}
}
if(a == 0 && b == 1) return 0;
else if(a == 1 && b == 2) return 1;
else if(a == 0 && b == 2) return 2;
else if(a == b) return a;
}