#include "Anthony.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector<int> graf[20005];
int dist[20005];
queue<int> Q;
int N;
bool prosli[20005];
void BFS(int gde){
for(int i=0;i<=N;i++)
dist[i]=-1;
dist[gde]=0;
Q.push(gde);
while(Q.size()){
int tren=Q.front();
Q.pop();
if(prosli[tren])
continue;
//cout<<tren<<endl;
prosli[tren]=true;
for(int i=0;i<graf[tren].size();i++)
if(dist[graf[tren][i]]==-1){
dist[graf[tren][i]]=dist[tren]+1;
Q.push(graf[tren][i]);
}
}
return;
}
vector<int> Mark(int n, int M, int A, int B, vector<int> U,vector<int> V) {
N=n;
for(int i=0;i<M;i++){
graf[U[i]].push_back(V[i]);
graf[V[i]].push_back(U[i]);
}
BFS(0);
/*for(int i=0;i<N;i++)
cout<<dist[i]<<" ";
cout<<endl;*/
if(B>=6 and M==N-1){
string S="001011";
vector<int> R;
for(int i=0;i<M;i++){
int md=min(dist[U[i]],dist[V[i]]);
R.push_back(S[md%6]-'0');
}
return R;
}
string S="012";
vector<int> R;
for(int i=0;i<M;i++){
int md=min(dist[U[i]],dist[V[i]]);
R.push_back(S[md%3]-'0');
}
return R;
}
#include "Catherine.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int slucaj,nalazi=0;
set<string> S;
void Init(int A, int B) {
if(A==2){
slucaj=2;
string x="001011";
x+=x;
x+=x;
for(int i=0;i+4<x.size();i++)
S.insert(x.substr(i,5));
}
else
slucaj=1;
}
string T;
int Move(std::vector<int> y) {
if(slucaj==1){
if(y[0]==0 and y[1]==0)
return 2;
if(y[0]==0 and y[2]==0)
return 1;
if(y[1]==0 and y[2]==0)
return 0;
if(y[0]==0)
return 1;
if(y[1]==0)
return 2;
return 0;
}
// cout<<"POTEZ "<<y[0]<<" "<<y[1]<<endl;
if(0==y[0] and y[1]==0){
nalazi=4;
return -1;
}
if(y[0]>y[1] and y[0]>1){
nalazi=4;
if(y[1]!=0)
return 1;
else
return -1;
}
if(y[0]<y[1] and y[1]>1){
nalazi=4;
if(y[0]!=0)
return 0;
else
return -1;
}
if(nalazi==0){
if(y[0]==0 and y[1]==1){
nalazi=4;
return 1;
}
if(y[1]==0 and y[0]==1){
nalazi=4;
return 0;
}
T+="01";
nalazi++;
return 1;
}
if(nalazi==1 or nalazi==2){
if(y[0]==1){
T+="0";
nalazi++;
return 0;
}
T+="1";
nalazi++;
return 1;
}
if(nalazi==3){
if(y[0]==1)
T+="0";
else
T+="1";
nalazi++;
if(S.find(T)!=S.end())
return -1;
if(y[0]==1)
return 0;
return 1;
}
if(y[0]==0){
nalazi=4;
return 1;
}
if(y[1]==0){
return 0;
}
return -1;
}
Compilation message
Anthony.cpp: In function 'void BFS(int)':
Anthony.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for(int i=0;i<graf[tren].size();i++)
| ~^~~~~~~~~~~~~~~~~~
Catherine.cpp: In function 'void Init(int, int)':
Catherine.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for(int i=0;i+4<x.size();i++)
| ~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
15828 KB |
Output is correct |
2 |
Correct |
1 ms |
1036 KB |
Output is correct |
3 |
Correct |
33 ms |
15252 KB |
Output is correct |
4 |
Correct |
55 ms |
16996 KB |
Output is correct |
5 |
Correct |
38 ms |
17148 KB |
Output is correct |
6 |
Correct |
28 ms |
15672 KB |
Output is correct |
7 |
Correct |
27 ms |
15668 KB |
Output is correct |
8 |
Correct |
32 ms |
16500 KB |
Output is correct |
9 |
Correct |
33 ms |
16440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
15828 KB |
Output is correct |
2 |
Correct |
1 ms |
1036 KB |
Output is correct |
3 |
Correct |
33 ms |
15252 KB |
Output is correct |
4 |
Correct |
55 ms |
16996 KB |
Output is correct |
5 |
Correct |
38 ms |
17148 KB |
Output is correct |
6 |
Correct |
28 ms |
15672 KB |
Output is correct |
7 |
Correct |
27 ms |
15668 KB |
Output is correct |
8 |
Correct |
32 ms |
16500 KB |
Output is correct |
9 |
Correct |
33 ms |
16440 KB |
Output is correct |
10 |
Correct |
26 ms |
13876 KB |
Output is correct |
11 |
Correct |
35 ms |
13764 KB |
Output is correct |
12 |
Correct |
27 ms |
13892 KB |
Output is correct |
13 |
Correct |
28 ms |
13612 KB |
Output is correct |
14 |
Correct |
33 ms |
14024 KB |
Output is correct |
15 |
Correct |
41 ms |
14436 KB |
Output is correct |
16 |
Correct |
31 ms |
16556 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
13488 KB |
Output is correct |
2 |
Correct |
1 ms |
1028 KB |
Output is correct |
3 |
Correct |
26 ms |
13020 KB |
Output is correct |
4 |
Correct |
40 ms |
14796 KB |
Output is correct |
5 |
Correct |
46 ms |
14768 KB |
Output is correct |
6 |
Correct |
33 ms |
13412 KB |
Output is correct |
7 |
Correct |
31 ms |
13548 KB |
Output is correct |
8 |
Correct |
39 ms |
14128 KB |
Output is correct |
9 |
Correct |
39 ms |
14088 KB |
Output is correct |
10 |
Correct |
30 ms |
13996 KB |
Output is correct |
11 |
Correct |
31 ms |
13860 KB |
Output is correct |
12 |
Correct |
46 ms |
13868 KB |
Output is correct |
13 |
Correct |
28 ms |
13876 KB |
Output is correct |
14 |
Correct |
34 ms |
14160 KB |
Output is correct |
15 |
Correct |
46 ms |
14204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
13488 KB |
Output is correct |
2 |
Correct |
1 ms |
1028 KB |
Output is correct |
3 |
Correct |
26 ms |
13020 KB |
Output is correct |
4 |
Correct |
40 ms |
14796 KB |
Output is correct |
5 |
Correct |
46 ms |
14768 KB |
Output is correct |
6 |
Correct |
33 ms |
13412 KB |
Output is correct |
7 |
Correct |
31 ms |
13548 KB |
Output is correct |
8 |
Correct |
39 ms |
14128 KB |
Output is correct |
9 |
Correct |
39 ms |
14088 KB |
Output is correct |
10 |
Correct |
30 ms |
13996 KB |
Output is correct |
11 |
Correct |
31 ms |
13860 KB |
Output is correct |
12 |
Correct |
46 ms |
13868 KB |
Output is correct |
13 |
Correct |
28 ms |
13876 KB |
Output is correct |
14 |
Correct |
34 ms |
14160 KB |
Output is correct |
15 |
Correct |
46 ms |
14204 KB |
Output is correct |
16 |
Correct |
28 ms |
11884 KB |
Output is correct |
17 |
Correct |
36 ms |
11944 KB |
Output is correct |
18 |
Correct |
37 ms |
11884 KB |
Output is correct |
19 |
Correct |
33 ms |
11872 KB |
Output is correct |
20 |
Correct |
27 ms |
12460 KB |
Output is correct |
21 |
Correct |
31 ms |
12208 KB |
Output is correct |
22 |
Correct |
45 ms |
14396 KB |
Output is correct |
23 |
Correct |
39 ms |
12008 KB |
Output is correct |
24 |
Correct |
31 ms |
12028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1300 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
11484 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
11560 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |