#include "Anthony.h"
#include <bits/stdc++.h>
#define debug //printf
#define pii pair<int,int>
#define ff first
#define ss second
#define mk make_pair
#define sz(x) (int)(x.size() )
#define ll long long
#define all(x) x.begin(),x.end()
const int MAXN = 2e4+10 ;
using namespace std ;
vector<pii> adj[MAXN] ;
vector<int> marcas ;
int seq[6] = {0,1,0,0,1,1} ;
void dfs(int x, int father , int curIdx , int dist = 1 ) //curIdx eh o que eu tenho que colocar nas minhas proximas arestas
{
if(x == 14851 ) debug("%d\n", dist ) ;
if( sz(adj[x]) != 2 ) curIdx = !seq[curIdx] ;
else curIdx = (curIdx == 5) ? 0 : (curIdx+1) ;
for(auto e : adj[x] )
{
if(e.ff == father ) continue ;
marcas[e.ss] = seq[curIdx] ;
dfs(e.ff, x, curIdx , dist+1 ) ;
}
}
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V)
{
for(int i = 0 ; i < M ; i++ )
{
adj[ U[i] ].push_back(mk(V[i] , i ) ) ;
adj[ V[i] ].push_back( mk(U[i],i) ) ;
}
marcas.resize(M, 0) ;
if(A >= 3 )
{
//Constroi a arvore da bfs
vector<int> fila ;
vector<int> dist(N, -1) ;
dist[0] = 0 ;
int ini = 0 ;
fila.push_back(0) ;
while(ini < sz(fila) )
{
int x = fila[ini++] ;
for(auto e : adj[x] )
{
if(dist[e.ff] != -1 )
{
if(dist[e.ff] < dist[x] ) continue ;
if(dist[e.ff] > dist[x] )
{
marcas[e.ss] = dist[e.ff] % 3 ;
}
else if (dist[e.ff] == dist[x] )
{
marcas[e.ss] = (dist[x] + 1 ) % 3 ;
}
}
fila.push_back(e.ff) ;
dist[e.ff] = dist[x] + 1 ;
marcas[e.ss] = dist[x] % 3 ;
}
}
}
else
{
for(auto neigh : adj[0] )
{
marcas[neigh.ss] = 0 ;
dfs(neigh.ff, 0, 0 ) ;
}
}
for(int i = 0 ; i < M ; i++ ) debug("Pintei %d %d de %d\n", U[i] , V[i] , marcas[i] ) ;
return marcas ;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#define debug //printf
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
using namespace std ;
set< string > reversedOrder ;
bool is3 ;
void Init(int A, int B)
{
string seq = "010011" ;
if(A >= 3 ) is3 = true ;
//Creating reversedOrder
for(int i = 0 ,ant = 5 ; i < 6 ; i++ , ant++ )
{
if(ant == 6 ) ant = 0 ;
string str ;
for(int j = i; j != ant ; j = (j == 5 ) ? 0 : (j+1) )
str.push_back(seq[j] ) ;
reversedOrder.insert(str) ;
}
}
bool justGo , isFirst = true ;
int wentBefore ;
string str ;
int Move(vector<int> y)
{
if(is3)
{
int qtdNeigh = y[0] + y[1] + y[2] ;
if(qtdNeigh == 1 )
{
for(int i = 0 ; i < 3 ; i++ )
if(y[i] ) return i ;
}
if( y[0] && y[1] ) return 0 ;
if(y[1] && y[2] ) return 1 ;
if(y[2] && y[0] ) return 2 ;
}
debug("meu vetor ta %d %d e justGo eh %d\n", y[0] , y[1] , justGo) ;
int qtdNeigh = y[0] + y[1] ;
if(qtdNeigh == 0)
{
justGo = true ;
return -1 ;
}
if(isFirst)
{
isFirst = false ;
if(qtdNeigh == 1 )
{
wentBefore = (y[0] == 1 ) ? 0 : 1 ;
justGo = true ;
return wentBefore ;
}
if(qtdNeigh == 2 )
{
if( y[0] && y[1] )
{
str.push_back('0') ;
str.push_back('1') ;
wentBefore = 1 ;
return 1 ;
}
int idx = (y[0] > y[1] ) ? 0 : 1 ;
str.push_back('0' + idx ) ;
str.push_back('0' + idx ) ;
wentBefore = idx ;
return idx ;
}
wentBefore = (y[0] < y[1] ) ? 0 : 1 ;
justGo = true ;
return wentBefore ;
}
if(justGo)
{
if( qtdNeigh == 1 )
{
wentBefore = (y[0] > y[1] ) ? 0 : 1 ;
return wentBefore ;
}
wentBefore = !wentBefore ;
return wentBefore ;
}
if(qtdNeigh > 1 )
{
justGo = true ;
if(y[!wentBefore] != 1 ) return -1 ;
wentBefore = !wentBefore;
return wentBefore;
}
//Ainda estou presa na corrente
str.push_back( '0' + ( (y[0] == 1) ? 0 : 1 ) ) ;
if(sz(str) == 5 )
{
justGo = true ;
if( reversedOrder.find(str) != reversedOrder.end() ) return -1 ;
else
{
wentBefore = (y[0] == 1 ) ? 0 : 1 ;
return wentBefore ;
}
}
wentBefore = (y[0] == 1 ) ? 0 : 1 ;
return wentBefore ;
}
Compilation message
Anthony.cpp: In function 'void dfs(int, int, int, int)':
Anthony.cpp:23:24: warning: left operand of comma operator has no effect [-Wunused-value]
23 | if(x == 14851 ) debug("%d\n", dist ) ;
| ^~~~~~
Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:107:38: warning: left operand of comma operator has no effect [-Wunused-value]
107 | for(int i = 0 ; i < M ; i++ ) debug("Pintei %d %d de %d\n", U[i] , V[i] , marcas[i] ) ;
| ^~~~~~~~~~~~~~~~~~~~~~
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:63:8: warning: left operand of comma operator has no effect [-Wunused-value]
63 | debug("meu vetor ta %d %d e justGo eh %d\n", y[0] , y[1] , justGo) ;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
15752 KB |
Output is correct |
2 |
Correct |
2 ms |
1536 KB |
Output is correct |
3 |
Correct |
42 ms |
15196 KB |
Output is correct |
4 |
Correct |
64 ms |
16756 KB |
Output is correct |
5 |
Correct |
64 ms |
16756 KB |
Output is correct |
6 |
Correct |
50 ms |
15452 KB |
Output is correct |
7 |
Correct |
50 ms |
15444 KB |
Output is correct |
8 |
Correct |
64 ms |
16320 KB |
Output is correct |
9 |
Correct |
61 ms |
16308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
15752 KB |
Output is correct |
2 |
Correct |
2 ms |
1536 KB |
Output is correct |
3 |
Correct |
42 ms |
15196 KB |
Output is correct |
4 |
Correct |
64 ms |
16756 KB |
Output is correct |
5 |
Correct |
64 ms |
16756 KB |
Output is correct |
6 |
Correct |
50 ms |
15452 KB |
Output is correct |
7 |
Correct |
50 ms |
15444 KB |
Output is correct |
8 |
Correct |
64 ms |
16320 KB |
Output is correct |
9 |
Correct |
61 ms |
16308 KB |
Output is correct |
10 |
Correct |
49 ms |
13832 KB |
Output is correct |
11 |
Correct |
48 ms |
13824 KB |
Output is correct |
12 |
Runtime error |
1837 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
13332 KB |
Output is correct |
2 |
Correct |
2 ms |
1536 KB |
Output is correct |
3 |
Correct |
39 ms |
13028 KB |
Output is correct |
4 |
Correct |
64 ms |
14588 KB |
Output is correct |
5 |
Correct |
62 ms |
14588 KB |
Output is correct |
6 |
Correct |
50 ms |
13304 KB |
Output is correct |
7 |
Correct |
48 ms |
13308 KB |
Output is correct |
8 |
Correct |
56 ms |
14256 KB |
Output is correct |
9 |
Correct |
57 ms |
14124 KB |
Output is correct |
10 |
Correct |
54 ms |
13868 KB |
Output is correct |
11 |
Correct |
53 ms |
13864 KB |
Output is correct |
12 |
Correct |
53 ms |
13872 KB |
Output is correct |
13 |
Correct |
53 ms |
13864 KB |
Output is correct |
14 |
Correct |
58 ms |
13980 KB |
Output is correct |
15 |
Correct |
58 ms |
14000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
13332 KB |
Output is correct |
2 |
Correct |
2 ms |
1536 KB |
Output is correct |
3 |
Correct |
39 ms |
13028 KB |
Output is correct |
4 |
Correct |
64 ms |
14588 KB |
Output is correct |
5 |
Correct |
62 ms |
14588 KB |
Output is correct |
6 |
Correct |
50 ms |
13304 KB |
Output is correct |
7 |
Correct |
48 ms |
13308 KB |
Output is correct |
8 |
Correct |
56 ms |
14256 KB |
Output is correct |
9 |
Correct |
57 ms |
14124 KB |
Output is correct |
10 |
Correct |
54 ms |
13868 KB |
Output is correct |
11 |
Correct |
53 ms |
13864 KB |
Output is correct |
12 |
Correct |
53 ms |
13872 KB |
Output is correct |
13 |
Correct |
53 ms |
13864 KB |
Output is correct |
14 |
Correct |
58 ms |
13980 KB |
Output is correct |
15 |
Correct |
58 ms |
14000 KB |
Output is correct |
16 |
Correct |
49 ms |
12528 KB |
Output is correct |
17 |
Correct |
45 ms |
12768 KB |
Output is correct |
18 |
Runtime error |
1904 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1536 KB |
Output is correct |
2 |
Correct |
2 ms |
1536 KB |
Output is correct |
3 |
Correct |
2 ms |
1536 KB |
Output is correct |
4 |
Correct |
2 ms |
1792 KB |
Output is correct |
5 |
Correct |
2 ms |
1792 KB |
Output is correct |
6 |
Correct |
2 ms |
1600 KB |
Output is correct |
7 |
Correct |
2 ms |
1792 KB |
Output is correct |
8 |
Correct |
2 ms |
1792 KB |
Output is correct |
9 |
Correct |
2 ms |
1792 KB |
Output is correct |
10 |
Correct |
2 ms |
1792 KB |
Output is correct |
11 |
Correct |
2 ms |
1792 KB |
Output is correct |
12 |
Correct |
2 ms |
1792 KB |
Output is correct |
13 |
Correct |
2 ms |
1792 KB |
Output is correct |
14 |
Correct |
3 ms |
1792 KB |
Output is correct |
15 |
Correct |
2 ms |
1792 KB |
Output is correct |
16 |
Correct |
2 ms |
1792 KB |
Output is correct |
17 |
Correct |
3 ms |
1536 KB |
Output is correct |
18 |
Correct |
2 ms |
1536 KB |
Output is correct |
19 |
Correct |
2 ms |
1536 KB |
Output is correct |
20 |
Correct |
2 ms |
1536 KB |
Output is correct |
21 |
Correct |
2 ms |
1792 KB |
Output is correct |
22 |
Correct |
2 ms |
1536 KB |
Output is correct |
23 |
Correct |
2 ms |
1536 KB |
Output is correct |
24 |
Correct |
2 ms |
1536 KB |
Output is correct |
25 |
Correct |
2 ms |
1536 KB |
Output is correct |
26 |
Correct |
2 ms |
1536 KB |
Output is correct |
27 |
Correct |
2 ms |
1536 KB |
Output is correct |
28 |
Correct |
2 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
11508 KB |
Output is correct |
2 |
Correct |
50 ms |
12572 KB |
Output is correct |
3 |
Correct |
1 ms |
1536 KB |
Output is correct |
4 |
Correct |
37 ms |
11324 KB |
Output is correct |
5 |
Correct |
57 ms |
14300 KB |
Output is correct |
6 |
Correct |
57 ms |
14068 KB |
Output is correct |
7 |
Correct |
49 ms |
13400 KB |
Output is correct |
8 |
Correct |
45 ms |
13300 KB |
Output is correct |
9 |
Correct |
56 ms |
14300 KB |
Output is correct |
10 |
Correct |
57 ms |
14068 KB |
Output is correct |
11 |
Correct |
57 ms |
14076 KB |
Output is correct |
12 |
Correct |
57 ms |
14068 KB |
Output is correct |
13 |
Correct |
59 ms |
14292 KB |
Output is correct |
14 |
Correct |
61 ms |
14224 KB |
Output is correct |
15 |
Correct |
58 ms |
14176 KB |
Output is correct |
16 |
Correct |
57 ms |
14124 KB |
Output is correct |
17 |
Correct |
63 ms |
13812 KB |
Output is correct |
18 |
Correct |
54 ms |
13900 KB |
Output is correct |
19 |
Correct |
59 ms |
13684 KB |
Output is correct |
20 |
Correct |
56 ms |
13912 KB |
Output is correct |
21 |
Correct |
53 ms |
13924 KB |
Output is correct |
22 |
Correct |
54 ms |
13692 KB |
Output is correct |
23 |
Correct |
44 ms |
11604 KB |
Output is correct |
24 |
Correct |
45 ms |
11644 KB |
Output is correct |
25 |
Correct |
46 ms |
11900 KB |
Output is correct |
26 |
Correct |
45 ms |
11988 KB |
Output is correct |
27 |
Correct |
54 ms |
12804 KB |
Output is correct |
28 |
Correct |
52 ms |
12796 KB |
Output is correct |
29 |
Correct |
53 ms |
12796 KB |
Output is correct |
30 |
Correct |
53 ms |
13052 KB |
Output is correct |
31 |
Correct |
49 ms |
11752 KB |
Output is correct |
32 |
Correct |
49 ms |
11752 KB |
Output is correct |
33 |
Correct |
44 ms |
11952 KB |
Output is correct |
34 |
Correct |
45 ms |
11964 KB |
Output is correct |
35 |
Correct |
52 ms |
12752 KB |
Output is correct |
36 |
Correct |
51 ms |
12744 KB |
Output is correct |
37 |
Correct |
53 ms |
12904 KB |
Output is correct |
38 |
Correct |
52 ms |
12540 KB |
Output is correct |
39 |
Correct |
52 ms |
12660 KB |
Output is correct |
40 |
Correct |
51 ms |
12668 KB |
Output is correct |
41 |
Correct |
54 ms |
13300 KB |
Output is correct |
42 |
Correct |
55 ms |
13420 KB |
Output is correct |
43 |
Correct |
58 ms |
13300 KB |
Output is correct |
44 |
Correct |
56 ms |
13416 KB |
Output is correct |
45 |
Correct |
55 ms |
13548 KB |
Output is correct |
46 |
Correct |
54 ms |
13424 KB |
Output is correct |
47 |
Correct |
50 ms |
12412 KB |
Output is correct |
48 |
Correct |
50 ms |
12284 KB |
Output is correct |
49 |
Correct |
47 ms |
12316 KB |
Output is correct |
50 |
Correct |
49 ms |
12588 KB |
Output is correct |
51 |
Correct |
45 ms |
11708 KB |
Output is correct |
52 |
Correct |
45 ms |
11644 KB |
Output is correct |
53 |
Correct |
45 ms |
11640 KB |
Output is correct |
54 |
Correct |
44 ms |
11636 KB |
Output is correct |
55 |
Correct |
48 ms |
11716 KB |
Output is correct |
56 |
Correct |
44 ms |
11696 KB |
Output is correct |
57 |
Correct |
45 ms |
11728 KB |
Output is correct |
58 |
Correct |
44 ms |
11884 KB |
Output is correct |
59 |
Correct |
47 ms |
11696 KB |
Output is correct |
60 |
Correct |
46 ms |
11728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
11388 KB |
Output is correct |
2 |
Correct |
47 ms |
12416 KB |
Output is correct |
3 |
Correct |
2 ms |
1536 KB |
Output is correct |
4 |
Correct |
37 ms |
11448 KB |
Output is correct |
5 |
Correct |
61 ms |
14068 KB |
Output is correct |
6 |
Correct |
58 ms |
14336 KB |
Output is correct |
7 |
Correct |
48 ms |
13308 KB |
Output is correct |
8 |
Correct |
46 ms |
13272 KB |
Output is correct |
9 |
Correct |
58 ms |
14172 KB |
Output is correct |
10 |
Correct |
58 ms |
14076 KB |
Output is correct |
11 |
Correct |
63 ms |
14424 KB |
Output is correct |
12 |
Correct |
61 ms |
14308 KB |
Output is correct |
13 |
Correct |
59 ms |
14164 KB |
Output is correct |
14 |
Correct |
61 ms |
14068 KB |
Output is correct |
15 |
Correct |
58 ms |
14296 KB |
Output is correct |
16 |
Correct |
62 ms |
14164 KB |
Output is correct |
17 |
Correct |
54 ms |
13912 KB |
Output is correct |
18 |
Correct |
55 ms |
13692 KB |
Output is correct |
19 |
Correct |
57 ms |
13908 KB |
Output is correct |
20 |
Correct |
58 ms |
13684 KB |
Output is correct |
21 |
Correct |
54 ms |
13920 KB |
Output is correct |
22 |
Correct |
57 ms |
13872 KB |
Output is correct |
23 |
Correct |
44 ms |
11500 KB |
Output is correct |
24 |
Correct |
43 ms |
11388 KB |
Output is correct |
25 |
Correct |
47 ms |
11984 KB |
Output is correct |
26 |
Correct |
46 ms |
12020 KB |
Output is correct |
27 |
Correct |
56 ms |
12796 KB |
Output is correct |
28 |
Correct |
51 ms |
12796 KB |
Output is correct |
29 |
Correct |
50 ms |
12796 KB |
Output is correct |
30 |
Correct |
53 ms |
12916 KB |
Output is correct |
31 |
Correct |
46 ms |
11616 KB |
Output is correct |
32 |
Correct |
43 ms |
11764 KB |
Output is correct |
33 |
Correct |
46 ms |
11976 KB |
Output is correct |
34 |
Correct |
49 ms |
11972 KB |
Output is correct |
35 |
Correct |
54 ms |
12540 KB |
Output is correct |
36 |
Correct |
50 ms |
12748 KB |
Output is correct |
37 |
Correct |
51 ms |
12752 KB |
Output is correct |
38 |
Correct |
53 ms |
12752 KB |
Output is correct |
39 |
Correct |
51 ms |
12660 KB |
Output is correct |
40 |
Correct |
52 ms |
12756 KB |
Output is correct |
41 |
Correct |
54 ms |
13300 KB |
Output is correct |
42 |
Correct |
54 ms |
13432 KB |
Output is correct |
43 |
Correct |
57 ms |
13384 KB |
Output is correct |
44 |
Correct |
54 ms |
13312 KB |
Output is correct |
45 |
Correct |
53 ms |
13604 KB |
Output is correct |
46 |
Correct |
53 ms |
13552 KB |
Output is correct |
47 |
Correct |
49 ms |
12440 KB |
Output is correct |
48 |
Correct |
49 ms |
12412 KB |
Output is correct |
49 |
Correct |
52 ms |
12440 KB |
Output is correct |
50 |
Correct |
49 ms |
12580 KB |
Output is correct |
51 |
Correct |
45 ms |
11824 KB |
Output is correct |
52 |
Correct |
45 ms |
11696 KB |
Output is correct |
53 |
Correct |
45 ms |
11704 KB |
Output is correct |
54 |
Correct |
44 ms |
11644 KB |
Output is correct |
55 |
Correct |
45 ms |
11692 KB |
Output is correct |
56 |
Correct |
47 ms |
11516 KB |
Output is correct |
57 |
Correct |
48 ms |
11720 KB |
Output is correct |
58 |
Correct |
44 ms |
11644 KB |
Output is correct |
59 |
Correct |
45 ms |
11744 KB |
Output is correct |
60 |
Correct |
44 ms |
11744 KB |
Output is correct |