#include <bits/stdc++.h>
#include "Anthony.h"
namespace {
int FunctionExample(int i, int A) { return i % A; }
} // namespace
using namespace std;
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
vector<int> X(M);
queue<pair<int, int>> q;
q.push({0, 0});
string s = "001011";
vector<pair<int, int>> g[N + 2];
for (int i = 0; i < M; i++) {
g[U[i]].push_back({V[i], i});
g[V[i]].push_back({U[i], i});
}
bool visited[N + 2];
memset(visited, 0, sizeof(visited));
visited[0] = 1;
while (q.size()) {
int cur = q.front().first, clr = q.front().second;
q.pop();
for (auto [to, id] : g[cur]) {
if (visited[to]) continue;
visited[to] = 1;
q.push({to, (clr + 1) % 6});
// cout << id << " : " << clr << endl;
X[id] = s[clr] - '0';
}
}
// for (int i = 0; i < X.size(); i++) cout << U[i] << " " << V[i] << " : " << X[i] << endl;
return X;
}
#include <bits/stdc++.h>
#include "Catherine.h"
using namespace std;
namespace {
int A, B;
int went;
string path;
bool wrong;
set<string> valid, invalid;
vector<string> vl, ivl;
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
vl = {"11010", "10100", "01001", "10011", "00110", "01101"};
ivl = {"00101", "10010", "11001", "01100", "10110", "01011"};
for (auto x : vl) valid.insert(x);
for (auto x : ivl) invalid.insert(x);
path = "";
went = 0;
wrong = 0;
}
int Move(vector<int> y) {
// cout << path << " " << went << endl;
if (went && wrong) {
went--;
path.pop_back();
return -1;
}
if (path.size() == 5) {
path = path.substr(1);
}
wrong = 0;
vector<pair<int, int>> total;
for (int i = 0; i < y.size(); i++) {
if (y[i]) total.push_back({y[i], i});
}
sort(total.begin(), total.end());
went++;
if (total.size() == 1 || total[0] < total[1]) {
path += to_string(total[0].second);
return total[0].second;
}
if (path.size() + 1 == 5) {
for (int i = 0; i < y.size(); i++) {
if (y[i]) {
string cur = path + to_string(i);
if (invalid.count(cur)) {
wrong = 1;
went -= 2;
path.pop_back();
return -1;
}
if (valid.count(cur)) {
path += to_string(i);
return i;
}
}
}
}
path += to_string(total[0].second);
return total[0].second;
}
Compilation message
Anthony.cpp:6:5: warning: 'int {anonymous}::FunctionExample(int, int)' defined but not used [-Wunused-function]
6 | int FunctionExample(int i, int A) { return i % A; }
| ^~~~~~~~~~~~~~~
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for (int i = 0; i < y.size(); i++) {
| ~~^~~~~~~~~~
Catherine.cpp:50:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for (int i = 0; i < y.size(); i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
35 ms |
27564 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
35 ms |
27564 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
31 ms |
23116 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
31 ms |
23116 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
1196 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
36 ms |
19520 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
32 ms |
19592 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |