QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#196325 | #2833. Hamilton | CSU2023# | WA | 0ms | 3620kb | C++14 | 1.7kb | 2023-10-01 15:52:55 | 2023-10-01 15:52:56 |
Judging History
answer
#include <bits/stdc++.h>
using std::ios;
using std::cin;
using std::cout;
const int N = 2005;
char c[N][N];
int n, p[N];
int main()
{
freopen("g.in", "r", stdin);
while (scanf("%d", &n) != EOF)
{
for (int i = 1; i <= n; ++i)
scanf("%s", c[i] + 1);
bool allsame = true;
p[1] = 1; p[2] = 2;
for (int i = 3; i <= n; ++i)
{
if (allsame)
{
if (c[i][p[i - 1]] != c[p[1]][p[2]])
allsame = false;
p[i] = i;
}
else
{
int j;
for (j = 2; j + 1 < i; ++j)
if (c[p[j - 1]][p[j]] != c[p[j]][p[j + 1]])
break ;
if (c[p[j]][i] == c[p[j]][p[j + 1]])
{
p[i] = i;
for (int k = i - 1; k >= j; --k)
std::swap(p[k], p[k + 1]);
}
else
{
p[i] = i;
for (int k = i - 1; k > j; --k)
std::swap(p[k], p[k + 1]);
}
allsame = true;
for (int j = 2; j < i; ++j)
if (c[p[j - 1]][p[j]] != c[p[j]][p[j + 1]])
allsame = false;
}
}
if (c[p[1]][p[2]] == c[p[n]][p[1]])
{
int temp = p[n];
for (int i = n - 1; i >= 1; --i)
p[i + 1] = p[i];
p[1] = temp;
}
for (int i = 1; i <= n; ++i)
printf("%d ", p[i]);
putchar('\n');
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3620kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
result:
wrong output format Unexpected end of file - int32 expected