QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#226620 | #6809. Code With No Forces | 326173163qqom# | RE | 1ms | 6020kb | C++20 | 2.6kb | 2023-10-26 11:01:01 | 2023-10-26 11:01:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 400 + 1, M = 6;
int n, m;
struct node
{
char c[5];
int x, y;
node()
{
c[0] = 'O';
}
void input()
{
scanf(" %c%c,%d/%d", c, c + 1, &x, &y);
}
} a[N][M], ans[M];
#define P pair<int, int>
P pre[1 << M * 3];
int tag[1 << M * 3];
int main()
{
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++)
for (int j = 0; j < m; j++)
a[i][j].input();
for (int i = 1; i <= n; i++)
{
for (int j = 0; j < m; j++)
{
if (ans[j].c[0] != 'O')
continue;
if (a[i][j].x > ans[j].x)
ans[j].x = a[i][j].x;
if (a[i][j].y > ans[j].y)
ans[j].y = a[i][j].y;
if (a[i][j].c[0] != 'O')
ans[j].c[0] = a[i][j].c[0];
}
}
tag[0] = 1;
int S = (1 << m * 3) - 1;
queue<int> q;
q.push(0);
while (!tag[S])
{
int u = q.front();
q.pop();
for (int i = 1; i <= n; i++)
{
int v = u;
for (int j = 0; j < m; j++)
{
if (v >> j * 3 & 1)
continue;
if (a[i][j].x > ans[j].x)
v = -1;
if (a[i][j].y > ans[j].y)
v = -1;
if (a[i][j].x == ans[j].x)
v |= 1 << j * 3 + 1;
if (a[i][j].y == ans[j].y)
v |= 1 << j * 3 + 2;
if (a[i][j].c[0] != 'O')
{
if (a[i][j].c[0] != ans[j].c[0])
{
v = -1;
break;
}
else
{
v |= 1 << j * 3;
}
}
else if (ans[j].c[0] == 'O')
v |= 1 << j * 3;
}
for (int j = 0; j < m; j++)
{
int x = v >> j * 3 & 7;
if ((x & 1) && x != 7)
{
v = -1;
break;
}
}
// cout << v << '\n';
if (v != -1 && !tag[v])
pre[v] = P(u, i), tag[v] = 1, q.push(v);
}
}
vector<int> out;
while (S != 0)
out.push_back(pre[S].second), S = pre[S].first;
cout << out.size() << '\n';
reverse(out.begin(), out.end());
for (auto v : out)
cout << v << ' ';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5792kb
input:
2 3 OK,1/1 OK,2/1 OK,2/2 WA,1/1 OK,1/1 TL,1000/1
output:
2 1 2
result:
ok ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 6020kb
input:
3 3 OK,1/1 OK,2/1 OK,1/2 OK,3/3 OK,1/2 OK,114/514 WA,999/999 TL,3000/2 ML,999/1024
output:
1 3
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
5 3 OK,0/0 OK,0/0 OK,0/0 WA,1/0 RE,0/0 OK,0/0 WA,0/0 WA,0/0 WA,0/0 OK,1/0 RE,0/0 OK,0/0 WA,2/2 RE,2/2 WA,2/2
output:
2 2 3
result:
ok ok
Test #4:
score: -100
Runtime Error
input:
21 6 OK,0/34 OK,15/1 OK,0/1 OK,0/4 OK,0/1 OK,0/36 OK,0/34 OK,0/1 OK,15/1 OK,15/4 OK,0/1 OK,0/36 OK,0/34 OK,15/1 OK,0/1 OK,0/4 OK,15/1 OK,0/36 OK,0/34 OK,0/1 OK,0/1 OK,0/4 OK,15/1 OK,0/36 OK,0/34 OK,0/1 OK,15/1 OK,0/4 OK,0/1 OK,0/36 OK,0/34 OK,0/1 OK,0/1 OK,0/4 OK,0/1 OK,0/36 OK,0/34 OK,0/1 OK,0/1 OK...