#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 = 2e5+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 ) //curIdx eh o que eu tenho que colocar nas minhas proximas arestas
{
for(auto e : adj[x] )
{
if(e.ff == father ) continue ;
marcas[e.ss] = seq[curIdx] ;
if( sz(adj[e.ff] ) == 2 ) dfs( e.ff, x , (curIdx == 5 ) ? 0 : (curIdx+1) ) ;
else dfs(e.ff, x, !seq[curIdx] ) ;
}
}
void dfs3(int x, int father, int toFill )
{
for(auto e : adj[x] )
{
if(e.ff == father) continue ;
marcas[e.ss] = toFill ;
dfs3(e.ff, x, (toFill == 2 ) ? 0 : (toFill+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 ) dfs3(0,-1, 0) ;
else dfs(0,-1,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 ;
void Init(int A, int B)
{
string seq = "010011" ;
//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)
{
debug("meu vetor ta %d %d\n", y[0] , y[1] ) ;
int qtdNeigh = y[0] + y[1] ;
if(qtdNeigh == 0)
{
justGo = true ;
return -1 ;
}
if(isFirst)
{
isFirst = false ;
if(qtdNeigh == 1 )
{
for(int i = 0 ; i < 2 ; i++)
if( y[i] )
{
wentBefore = i ;
justGo = true ;
return i ;
}
}
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 )
{
int idx = (y[0] > y[1] ) ? 0 : 1 ;
wentBefore = idx ;
return idx ;
}
wentBefore = !wentBefore ;
return wentBefore ;
}
if(qtdNeigh > 1 )
{
justGo = true ;
if(!y[0] || !y[1] ) return -1 ;
int idx = (y[0] == 1) ? 0 : 1 ;
wentBefore = idx ;
return idx ;
}
//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 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:66:38: warning: left operand of comma operator has no effect [-Wunused-value]
66 | 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:43:8: warning: left operand of comma operator has no effect [-Wunused-value]
43 | debug("meu vetor ta %d %d\n", y[0] , y[1] ) ;
| ^~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
20252 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
20252 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
18076 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
18076 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
9984 KB |
Output is correct |
2 |
Correct |
5 ms |
9984 KB |
Output is correct |
3 |
Correct |
5 ms |
9984 KB |
Output is correct |
4 |
Correct |
5 ms |
10240 KB |
Output is correct |
5 |
Correct |
5 ms |
10240 KB |
Output is correct |
6 |
Correct |
5 ms |
10240 KB |
Output is correct |
7 |
Correct |
6 ms |
10240 KB |
Output is correct |
8 |
Correct |
5 ms |
10240 KB |
Output is correct |
9 |
Correct |
5 ms |
10240 KB |
Output is correct |
10 |
Correct |
5 ms |
10240 KB |
Output is correct |
11 |
Correct |
5 ms |
10240 KB |
Output is correct |
12 |
Correct |
5 ms |
10240 KB |
Output is correct |
13 |
Correct |
6 ms |
10240 KB |
Output is correct |
14 |
Correct |
5 ms |
10240 KB |
Output is correct |
15 |
Correct |
5 ms |
10240 KB |
Output is correct |
16 |
Correct |
5 ms |
10240 KB |
Output is correct |
17 |
Correct |
5 ms |
10240 KB |
Output is correct |
18 |
Correct |
5 ms |
9984 KB |
Output is correct |
19 |
Correct |
5 ms |
9984 KB |
Output is correct |
20 |
Correct |
5 ms |
10240 KB |
Output is correct |
21 |
Correct |
5 ms |
10240 KB |
Output is correct |
22 |
Correct |
5 ms |
10240 KB |
Output is correct |
23 |
Correct |
5 ms |
10240 KB |
Output is correct |
24 |
Correct |
5 ms |
10240 KB |
Output is correct |
25 |
Correct |
5 ms |
10240 KB |
Output is correct |
26 |
Correct |
6 ms |
10240 KB |
Output is correct |
27 |
Correct |
5 ms |
10240 KB |
Output is correct |
28 |
Correct |
5 ms |
10240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
15824 KB |
Output is correct |
2 |
Correct |
53 ms |
16980 KB |
Output is correct |
3 |
Correct |
4 ms |
9984 KB |
Output is correct |
4 |
Correct |
41 ms |
15480 KB |
Output is correct |
5 |
Correct |
62 ms |
17908 KB |
Output is correct |
6 |
Correct |
62 ms |
18056 KB |
Output is correct |
7 |
Correct |
50 ms |
17688 KB |
Output is correct |
8 |
Correct |
49 ms |
17484 KB |
Output is correct |
9 |
Correct |
61 ms |
18440 KB |
Output is correct |
10 |
Correct |
63 ms |
18516 KB |
Output is correct |
11 |
Correct |
61 ms |
18440 KB |
Output is correct |
12 |
Correct |
61 ms |
18572 KB |
Output is correct |
13 |
Correct |
62 ms |
18704 KB |
Output is correct |
14 |
Correct |
61 ms |
18448 KB |
Output is correct |
15 |
Correct |
63 ms |
18572 KB |
Output is correct |
16 |
Correct |
63 ms |
18372 KB |
Output is correct |
17 |
Correct |
56 ms |
18208 KB |
Output is correct |
18 |
Correct |
57 ms |
18328 KB |
Output is correct |
19 |
Correct |
59 ms |
18176 KB |
Output is correct |
20 |
Correct |
57 ms |
18180 KB |
Output is correct |
21 |
Correct |
62 ms |
18192 KB |
Output is correct |
22 |
Correct |
59 ms |
18004 KB |
Output is correct |
23 |
Correct |
49 ms |
16084 KB |
Output is correct |
24 |
Correct |
49 ms |
16100 KB |
Output is correct |
25 |
Correct |
49 ms |
16516 KB |
Output is correct |
26 |
Correct |
49 ms |
16460 KB |
Output is correct |
27 |
Correct |
57 ms |
17444 KB |
Output is correct |
28 |
Correct |
55 ms |
17356 KB |
Output is correct |
29 |
Correct |
55 ms |
17220 KB |
Output is correct |
30 |
Correct |
54 ms |
17364 KB |
Output is correct |
31 |
Correct |
48 ms |
16076 KB |
Output is correct |
32 |
Correct |
51 ms |
15996 KB |
Output is correct |
33 |
Correct |
47 ms |
16464 KB |
Output is correct |
34 |
Correct |
48 ms |
16336 KB |
Output is correct |
35 |
Correct |
54 ms |
17072 KB |
Output is correct |
36 |
Correct |
55 ms |
16980 KB |
Output is correct |
37 |
Correct |
55 ms |
17124 KB |
Output is correct |
38 |
Correct |
54 ms |
17112 KB |
Output is correct |
39 |
Correct |
55 ms |
17156 KB |
Output is correct |
40 |
Correct |
54 ms |
17108 KB |
Output is correct |
41 |
Correct |
55 ms |
17864 KB |
Output is correct |
42 |
Correct |
56 ms |
17856 KB |
Output is correct |
43 |
Correct |
60 ms |
17832 KB |
Output is correct |
44 |
Correct |
60 ms |
17740 KB |
Output is correct |
45 |
Correct |
57 ms |
17860 KB |
Output is correct |
46 |
Correct |
56 ms |
17868 KB |
Output is correct |
47 |
Correct |
56 ms |
17064 KB |
Output is correct |
48 |
Correct |
52 ms |
16980 KB |
Output is correct |
49 |
Correct |
58 ms |
16928 KB |
Output is correct |
50 |
Correct |
55 ms |
17236 KB |
Output is correct |
51 |
Correct |
47 ms |
16212 KB |
Output is correct |
52 |
Correct |
49 ms |
16204 KB |
Output is correct |
53 |
Correct |
49 ms |
16332 KB |
Output is correct |
54 |
Correct |
47 ms |
16440 KB |
Output is correct |
55 |
Correct |
48 ms |
16440 KB |
Output is correct |
56 |
Correct |
48 ms |
16420 KB |
Output is correct |
57 |
Incorrect |
45 ms |
16468 KB |
Wrong Answer [6] |
58 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
15644 KB |
Output is correct |
2 |
Correct |
52 ms |
16508 KB |
Output is correct |
3 |
Correct |
4 ms |
9984 KB |
Output is correct |
4 |
Correct |
41 ms |
15352 KB |
Output is correct |
5 |
Correct |
65 ms |
18060 KB |
Output is correct |
6 |
Correct |
66 ms |
18068 KB |
Output is correct |
7 |
Correct |
50 ms |
17684 KB |
Output is correct |
8 |
Correct |
51 ms |
17652 KB |
Output is correct |
9 |
Correct |
61 ms |
18444 KB |
Output is correct |
10 |
Correct |
60 ms |
18392 KB |
Output is correct |
11 |
Correct |
62 ms |
18380 KB |
Output is correct |
12 |
Correct |
61 ms |
18380 KB |
Output is correct |
13 |
Correct |
62 ms |
18384 KB |
Output is correct |
14 |
Correct |
60 ms |
18560 KB |
Output is correct |
15 |
Correct |
63 ms |
18380 KB |
Output is correct |
16 |
Correct |
62 ms |
18576 KB |
Output is correct |
17 |
Correct |
60 ms |
18192 KB |
Output is correct |
18 |
Correct |
56 ms |
18004 KB |
Output is correct |
19 |
Correct |
59 ms |
18324 KB |
Output is correct |
20 |
Correct |
60 ms |
18192 KB |
Output is correct |
21 |
Correct |
64 ms |
17996 KB |
Output is correct |
22 |
Correct |
60 ms |
18184 KB |
Output is correct |
23 |
Correct |
47 ms |
16092 KB |
Output is correct |
24 |
Correct |
47 ms |
16104 KB |
Output is correct |
25 |
Correct |
50 ms |
16520 KB |
Output is correct |
26 |
Correct |
50 ms |
16336 KB |
Output is correct |
27 |
Correct |
55 ms |
17356 KB |
Output is correct |
28 |
Correct |
55 ms |
17364 KB |
Output is correct |
29 |
Correct |
59 ms |
17236 KB |
Output is correct |
30 |
Correct |
55 ms |
17416 KB |
Output is correct |
31 |
Correct |
46 ms |
16096 KB |
Output is correct |
32 |
Correct |
47 ms |
16084 KB |
Output is correct |
33 |
Correct |
50 ms |
16640 KB |
Output is correct |
34 |
Correct |
51 ms |
16340 KB |
Output is correct |
35 |
Correct |
55 ms |
17104 KB |
Output is correct |
36 |
Correct |
55 ms |
17108 KB |
Output is correct |
37 |
Correct |
54 ms |
17140 KB |
Output is correct |
38 |
Correct |
54 ms |
17108 KB |
Output is correct |
39 |
Correct |
56 ms |
17116 KB |
Output is correct |
40 |
Correct |
53 ms |
17108 KB |
Output is correct |
41 |
Correct |
56 ms |
17848 KB |
Output is correct |
42 |
Correct |
55 ms |
17876 KB |
Output is correct |
43 |
Correct |
61 ms |
17736 KB |
Output is correct |
44 |
Correct |
57 ms |
17992 KB |
Output is correct |
45 |
Correct |
60 ms |
18124 KB |
Output is correct |
46 |
Correct |
56 ms |
17872 KB |
Output is correct |
47 |
Correct |
54 ms |
16972 KB |
Output is correct |
48 |
Correct |
53 ms |
16980 KB |
Output is correct |
49 |
Correct |
55 ms |
16844 KB |
Output is correct |
50 |
Correct |
53 ms |
16980 KB |
Output is correct |
51 |
Correct |
47 ms |
16424 KB |
Output is correct |
52 |
Correct |
48 ms |
16380 KB |
Output is correct |
53 |
Correct |
47 ms |
16424 KB |
Output is correct |
54 |
Correct |
47 ms |
16432 KB |
Output is correct |
55 |
Correct |
47 ms |
16436 KB |
Output is correct |
56 |
Correct |
49 ms |
16428 KB |
Output is correct |
57 |
Correct |
49 ms |
16464 KB |
Output is correct |
58 |
Correct |
50 ms |
16428 KB |
Output is correct |
59 |
Correct |
49 ms |
16220 KB |
Output is correct |
60 |
Correct |
50 ms |
16340 KB |
Output is correct |