#include "Anna.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
namespace {
int next_cnt (int x) {
if (x == 9) return 1;
return x + 1;
}
} // namespace
void Anna(int n, int k, std::vector<int> r, std::vector<int> c) {
int start = 1;
vector<vector<int> > label(n, vector<int> (n));
vector<vector<int> > ret(n, vector<int> (n));
for(int i = 0; i < n; i++) {
int cnt = start;
for(int j = 0; j < n; j++) {
label[i][j] = cnt;
cnt = next_cnt(cnt);
}
start += 3;
if (start > 9) start -= 9;
}
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if (label[i][j] <= k) {
int x = r[label[i][j] - 1];
int y = c[label[i][j] - 1];
ret[i][j] = 0;
if (j + 1 < y) ret[i][j] = 1;
if (j - 1 > y) ret[i][j] = 2;
if (i + 1 < x) ret[i][j] = 3;
if (i - 1 > x) ret[i][j] = 4;
if (ret[i][j] == 0) {
ret[i][j] = 4 + (x - i + 1) * 3 + y - j + 2;
}
// if (i == 1 && j == 0) cout << x << " " << y << endl;
}
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if (label[i][j] == 9) ret[i][j] = 13;
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if (label[i][j] == 8) ret[i][j] = 1;
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) SetFlag(i, j, ret[i][j]);
// for(int i = 0; i < n; i++) {
// for(int j = 0; j < n; j++) cout << ret[i][j] << " ";
// cout << endl;
// }
// exit(0);
}
#include "Bruno.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
namespace {
//int next_cnt (int x) {
// if (x == 9) return 1;
// return x + 1;
//}
int variable_example = 1;
} // namespace
int Move (int i, int j, int x, int y) {
if (j < y) return 0;
if (j > y) return 1;
if (i < x) return 2;
if (i > x) return 3;
return 4;
}
std::vector<int> Bruno(int k, std::vector<int> value) {
// exit(0);
vector<vector<int> > a(3, vector<int> (3));
vector<vector<int> > b(3, vector<int> (3));
vector<int> ret(k);
int cnt = 0;
for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) {
a[i][j] = value[cnt++];
}
for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) if (a[i][j] == 13) {
b[i][j] = 9;
int x = i, y = j;
for(int loop = 1; loop <= 8; loop++) {
if (y + 1 < 3) y++;
else {
x++;
if (x == 3) x = 0;
y = 0;
}
b[x][y] = loop;
}
}
// exit(0);
// for(int i = 0; i < 3; i++) {
// for(int j = 0; j < 3; j++) cout << b[i][j] << " "; cout << endl;
// }
for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) if (b[i][j] <= 7) {
if (a[i][j] <= 4) {
ret[b[i][j] - 1] = a[i][j] - 1;
}
else {
a[i][j] -= 5;
int x = a[i][j] / 3 + i - 1;
int y = a[i][j] % 3 + j - 1;
ret[b[i][j] - 1] = Move(1, 1, x, y);
}
}
// for(int &j : ret) cout << j << " ";
// exit(0);
return ret;
}
Compilation message
Bruno.cpp:13:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
13 | int variable_example = 1;
| ^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
8 ms |
924 KB |
Partially correct |
2 |
Partially correct |
8 ms |
672 KB |
Partially correct |
3 |
Partially correct |
7 ms |
664 KB |
Partially correct |
4 |
Partially correct |
8 ms |
676 KB |
Partially correct |
5 |
Incorrect |
1 ms |
332 KB |
Wrong Answer [7] |
6 |
Halted |
0 ms |
0 KB |
- |