QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#856067 | #3102. Navigation 2 | Max_s_xaM | 0 | 1ms | 3968kb | C++20 | 3.7kb | 2025-01-13 15:36:29 | 2025-01-13 15:36:31 |
Anna
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <random>
#include <ctime>
#include <chrono>
#include <numeric>
#include <iomanip>
#include <cassert>
#include "Anna.h"
typedef long long ll;
typedef double lf;
typedef unsigned long long ull;
using namespace std;
namespace
{
const int MAXN = 110;
int n, a[MAXN][MAXN];
vector <int> R, C;
map <pair <int, int>, int> mp;
int tp[3][3]; bool apr[15];
inline bool Mark(int s, int t)
{
for (int i = 0, k = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
tp[(s + i) % 3][(t + j) % 3] = k - 2, k++;
memset(apr, 0, sizeof(apr));
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
{
if (tp[i % 3][j % 3] < 0) continue;
int c = tp[i % 3][j % 3];
if (mp[{i - R[c], j - C[c]}]) a[i][j] = mp[{i - R[c], j - C[c]}];
else if (i < R[c] - 1) a[i][j] = 10;
else if (i > R[c] + 1) a[i][j] = 11;
else a[i][j] = 12 + (j > C[c]);
if (a[i][j] == 9) return 0;
apr[a[i][j]] = 1;
}
int p = 1; while (apr[p]) p++;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (tp[i % 3][j % 3] == -2) a[i][j] = 12;
else if (tp[i % 3][j % 3] == -1) a[i][j] = p;
else a[i][j] -= (a[i][j] > p) + (a[i][j] > 9);
return 1;
}
}
void Anna(int N, int K, vector <int> R, vector <int> C)
{
n = N, ::R = R, ::C = C;
for (int i = -1, k = 0; i < 2; i++)
for (int j = -1; j < 2; j++)
mp[{i, j}] = ++k;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
if (Mark(i, j))
{
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
SetFlag(i, j, a[i][j]);
return;
}
}
Bruno
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <random>
#include <ctime>
#include <chrono>
#include <numeric>
#include <iomanip>
#include <cassert>
#include "Bruno.h"
typedef long long ll;
typedef double lf;
typedef unsigned long long ull;
using namespace std;
namespace
{
map <int, pair <int, int>> mp;
}
vector <int> Bruno(int K, vector <int> val)
{
for (int i = -1, k = 0; i < 2; i++)
for (int j = -1; j < 2; j++)
mp[++k] = {i, j};
int s = 0, t = 0;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
if (val[i * 3 + j] == 12) { s = i, t = j; break; }
int p = val[s * 3 + (t + 1) % 3];
for (int i = 0; i < 9; i++)
val[i] += (val[i] >= p), val[i] += (val[i] >= 9);
vector <int> ans(K);
for (int i = 0, k = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
if (i * 3 + j > 1)
{
int xx = (s + i) % 3, yy = (t + j) % 3;
int c = val[xx * 3 + yy];
int x = 0, y = 0;
if (c <= 9) x = xx - mp[c].first, y = yy - mp[c].second;
else if (c == 10) x = xx + 2;
else if (c == 11) x = xx - 2;
else if (c == 12) y = yy + 2;
else y = yy - 2;
if (1 == x && 1 == y) ans[k] = 4;
else if (1 < y) ans[k] = 0;
else if (1 > y) ans[k] = 1;
else if (1 < x) ans[k] = 2;
else ans[k] = 3;
k++;
}
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3968kb
input:
288 7 3 12 4 7 2 11 6 9 9
output:
1 2 1 1 1 1 4
input:
output:
Wrong Answer [7]
result:
wrong answer