#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
std::vector<int> Mark(int N, int M, int A, int B,
std::vector<int> U, std::vector<int> V)
{
vector<vector<ii>> ADJ(N);
map<ii, int> paths;
vector<bool> filled(M, false);
for (int i = 0; i < M; i++) {
ADJ[U[i]].push_back({V[i], i});
ADJ[V[i]].push_back({U[i], i});
paths[{U[i], V[i]}] = i;
paths[{V[i], U[i]}] = i;
}
std::vector<int> X(M);
priority_queue<ii, vector<ii>, greater<ii>> q;
vector<int> prevNode(N, -1);
vector<int> shortest(N, 1e8);
shortest[0] = 0;
q.push({0,0});
while (!q.empty()) {
auto [dis, pos] = q.top();
q.pop();
if (dis != shortest[pos]) continue;
for (auto [conn, _] : ADJ[pos]) {
if (dis+1 < shortest[conn]) {
shortest[conn] = dis+1;
prevNode[conn] = pos;
q.push({dis+1, conn});
}
}
}
for (int p = 1; p < N; p++) {
X[paths[{p, prevNode[p]}]] = shortest[p]%(A==2?2:3);
filled[paths[{p, prevNode[p]}]] = true;
}
for (int i = 0; i < M; i++) if (!filled[i]) {
X[i] = (min(shortest[U[i]], shortest[V[i]])+1)%(A==2?2:3);
}
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace
{
int A, B;
int prevA = 0;
bool onPath = false;
bool first = true;
} // namespace
void Init(int A, int B)
{
::A = A;
::B = B;
}
int Move(std::vector<int> y)
{
if (A==2) {
if (!::onPath) {
if (y[0]==0 ^ y[1]==0) {
if (first) {
::onPath = true;
::prevA = y[0]?0:1;
return y[0]?0:1;
} else {
::prevA = !::prevA;
return ::prevA;
}
}
if (y[0]==1 && y[1]==1) {
return 0;
}
if (y[0]==0 && y[1]==0) {
return -1;
}
::prevA = y[0]==1?0:1;
} else {
::prevA = !::prevA;
return ::prevA;
}
} else {
first = false;
int corr = -1;
for (int p = 0 ; p < y.size(); p++) if (y[p] && (corr==-1 || (corr==0&&p==2))) corr = p;
return corr;
}
}
Compilation message
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:27:21: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
27 | if (y[0]==0 ^ y[1]==0) {
Catherine.cpp:51:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | for (int p = 0 ; p < y.size(); p++) if (y[p] && (corr==-1 || (corr==0&&p==2))) corr = p;
| ~~^~~~~~~~~~
Catherine.cpp:43:21: warning: control reaches end of non-void function [-Wreturn-type]
43 | ::prevA = y[0]==1?0:1;
| ~~~~~~~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
18020 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
39 ms |
17428 KB |
Output is correct |
4 |
Correct |
51 ms |
19156 KB |
Output is correct |
5 |
Correct |
49 ms |
19052 KB |
Output is correct |
6 |
Correct |
44 ms |
17836 KB |
Output is correct |
7 |
Correct |
43 ms |
17832 KB |
Output is correct |
8 |
Correct |
46 ms |
18592 KB |
Output is correct |
9 |
Correct |
45 ms |
18580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
18020 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
39 ms |
17428 KB |
Output is correct |
4 |
Correct |
51 ms |
19156 KB |
Output is correct |
5 |
Correct |
49 ms |
19052 KB |
Output is correct |
6 |
Correct |
44 ms |
17836 KB |
Output is correct |
7 |
Correct |
43 ms |
17832 KB |
Output is correct |
8 |
Correct |
46 ms |
18592 KB |
Output is correct |
9 |
Correct |
45 ms |
18580 KB |
Output is correct |
10 |
Correct |
51 ms |
15940 KB |
Output is correct |
11 |
Correct |
46 ms |
15972 KB |
Output is correct |
12 |
Correct |
41 ms |
15856 KB |
Output is correct |
13 |
Correct |
41 ms |
15940 KB |
Output is correct |
14 |
Correct |
40 ms |
16140 KB |
Output is correct |
15 |
Correct |
44 ms |
16480 KB |
Output is correct |
16 |
Correct |
44 ms |
18616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
15472 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
37 ms |
15192 KB |
Output is correct |
4 |
Correct |
59 ms |
16692 KB |
Output is correct |
5 |
Correct |
52 ms |
16708 KB |
Output is correct |
6 |
Correct |
41 ms |
15580 KB |
Output is correct |
7 |
Correct |
43 ms |
15584 KB |
Output is correct |
8 |
Correct |
45 ms |
16020 KB |
Output is correct |
9 |
Correct |
50 ms |
16108 KB |
Output is correct |
10 |
Correct |
44 ms |
15744 KB |
Output is correct |
11 |
Correct |
43 ms |
15816 KB |
Output is correct |
12 |
Correct |
43 ms |
15764 KB |
Output is correct |
13 |
Correct |
43 ms |
15768 KB |
Output is correct |
14 |
Correct |
45 ms |
16136 KB |
Output is correct |
15 |
Correct |
46 ms |
16252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
15472 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
37 ms |
15192 KB |
Output is correct |
4 |
Correct |
59 ms |
16692 KB |
Output is correct |
5 |
Correct |
52 ms |
16708 KB |
Output is correct |
6 |
Correct |
41 ms |
15580 KB |
Output is correct |
7 |
Correct |
43 ms |
15584 KB |
Output is correct |
8 |
Correct |
45 ms |
16020 KB |
Output is correct |
9 |
Correct |
50 ms |
16108 KB |
Output is correct |
10 |
Correct |
44 ms |
15744 KB |
Output is correct |
11 |
Correct |
43 ms |
15816 KB |
Output is correct |
12 |
Correct |
43 ms |
15764 KB |
Output is correct |
13 |
Correct |
43 ms |
15768 KB |
Output is correct |
14 |
Correct |
45 ms |
16136 KB |
Output is correct |
15 |
Correct |
46 ms |
16252 KB |
Output is correct |
16 |
Correct |
39 ms |
13996 KB |
Output is correct |
17 |
Correct |
39 ms |
14080 KB |
Output is correct |
18 |
Correct |
40 ms |
13840 KB |
Output is correct |
19 |
Correct |
39 ms |
13860 KB |
Output is correct |
20 |
Correct |
41 ms |
14436 KB |
Output is correct |
21 |
Correct |
48 ms |
14108 KB |
Output is correct |
22 |
Correct |
49 ms |
16268 KB |
Output is correct |
23 |
Correct |
40 ms |
13900 KB |
Output is correct |
24 |
Correct |
43 ms |
13904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
1164 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
13760 KB |
Output is correct |
2 |
Incorrect |
39 ms |
13728 KB |
Wrong Answer [5] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
39 ms |
13716 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |