#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], uu, vv;
int pattern[6] = { 0, 0, 1, 0, 1, 1 };
vector<int> X;
void dfs( int u, int p, int t ) {
if ( p != -1 && adj[u].size() == 2 )
t = (t + 1) % 6;
else
t = (pattern[t] == 0 ? 2 : 0);
for ( int e: adj[u] ) {
if ( e == p )
continue;
X[e] = pattern[t];
int v = (uu[e] == u ? vv[e] : uu[e]);
dfs( v, e, t );
}
}
vector<int> Mark( int N, int M, int A, int B, vector<int> U, vector<int> V ) {
X.resize( M );
uu = U;
vv = V;
for ( int i = 0; i < M; i++ ) {
adj[U[i]].push_back( i );
adj[V[i]].push_back( i );
}
if ( A == 3 ) {
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 );
}
}
} else {
dfs( 0, -1, 0 );
}
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
set<string> down;
int A, B;
void Init( int a, int b ) {
A = a;
B = b;
down.insert( "00101" );
down.insert( "01011" );
down.insert( "10110" );
down.insert( "01100" );
down.insert( "11001" );
down.insert( "10010" );
}
//001011 001011
int t = 0, p = -1;
bool dir = false;
string s = "";
int Move( vector<int> y ) {
if ( A == 3 ) {
if ( y[0] > 0 && y[2] == 0 )
return 0;
if ( y[1] > 0 && y[0] == 0 )
return 1;
if ( y[2] > 0 && y[1] == 0 )
return 2;
} else {
if ( y[0] + y[1] == 0 ) {
dir = true;
return -1;
}
if ( y[0] + y[1] + (t > 0) > 2 ) {
y[t]++;
dir = true;
return (y[0] == 1 ? 0 : 1);
}
if ( dir )
return (y[0] == 1 ? 0 : 1);
while ( y[0] > 0 ) {
s += '0';
y[0]--;
}
while ( y[1] > 0 ) {
s += '1';
y[1]--;
}
if ( t == 3 ) {
dir = true;
if ( down.find( s ) != down.end() )
return -1;
}
return s.back() - '0';
}
}
Compilation message
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
62 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
27 ms |
16340 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
27 ms |
16340 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
13600 KB |
Output is correct |
2 |
Correct |
1 ms |
1312 KB |
Output is correct |
3 |
Correct |
25 ms |
13360 KB |
Output is correct |
4 |
Correct |
34 ms |
15180 KB |
Output is correct |
5 |
Correct |
33 ms |
15164 KB |
Output is correct |
6 |
Correct |
30 ms |
13628 KB |
Output is correct |
7 |
Correct |
26 ms |
13812 KB |
Output is correct |
8 |
Correct |
31 ms |
14420 KB |
Output is correct |
9 |
Correct |
32 ms |
14420 KB |
Output is correct |
10 |
Correct |
28 ms |
14192 KB |
Output is correct |
11 |
Correct |
36 ms |
14136 KB |
Output is correct |
12 |
Correct |
32 ms |
14168 KB |
Output is correct |
13 |
Correct |
31 ms |
14152 KB |
Output is correct |
14 |
Correct |
31 ms |
14408 KB |
Output is correct |
15 |
Correct |
31 ms |
14824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
13600 KB |
Output is correct |
2 |
Correct |
1 ms |
1312 KB |
Output is correct |
3 |
Correct |
25 ms |
13360 KB |
Output is correct |
4 |
Correct |
34 ms |
15180 KB |
Output is correct |
5 |
Correct |
33 ms |
15164 KB |
Output is correct |
6 |
Correct |
30 ms |
13628 KB |
Output is correct |
7 |
Correct |
26 ms |
13812 KB |
Output is correct |
8 |
Correct |
31 ms |
14420 KB |
Output is correct |
9 |
Correct |
32 ms |
14420 KB |
Output is correct |
10 |
Correct |
28 ms |
14192 KB |
Output is correct |
11 |
Correct |
36 ms |
14136 KB |
Output is correct |
12 |
Correct |
32 ms |
14168 KB |
Output is correct |
13 |
Correct |
31 ms |
14152 KB |
Output is correct |
14 |
Correct |
31 ms |
14408 KB |
Output is correct |
15 |
Correct |
31 ms |
14824 KB |
Output is correct |
16 |
Correct |
24 ms |
12028 KB |
Output is correct |
17 |
Correct |
23 ms |
12104 KB |
Output is correct |
18 |
Correct |
25 ms |
12108 KB |
Output is correct |
19 |
Correct |
25 ms |
12100 KB |
Output is correct |
20 |
Correct |
27 ms |
12792 KB |
Output is correct |
21 |
Correct |
26 ms |
12604 KB |
Output is correct |
22 |
Correct |
28 ms |
14676 KB |
Output is correct |
23 |
Correct |
25 ms |
12372 KB |
Output is correct |
24 |
Correct |
25 ms |
12356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1564 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
11848 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
11852 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |