QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375537#2833. HamiltonFido_PuppyWA 0ms3776kbC++231.6kb2024-04-03 12:05:342024-04-03 12:05:35

Judging History

你现在查看的是最新测评结果

  • [2024-04-03 12:05:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3776kb
  • [2024-04-03 12:05:34]
  • 提交

answer

#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define MT make_tuple
#define IT iterator
#define fi first
#define se second
#define For(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define Rep(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define CLR(a, v) memset(a, v, sizeof(a))
#define CPY(a, b) memcpy(a, b, sizeof(a))
#define debug cerr << "ztxakking\n"
#define y0 ztxaknoi
#define y1 ztxakioi
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using vi = vector<int>;
template<typename T>
using V = vector<T>;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e3 + 7;
int n, a[N][N];
vi p;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  while (cin >> n) {
    For(i, 1, n) For(j, 1, n) {
      char c; cin >> c, a[i][j] = c - 48;
    }
    p.clear(), p = {1, 2};
    For(i, 2, n - 1) {
      For(j, 1, i - 1) if (a[p[j]][p[j - 1]] != a[p[j]][p[(j + 1) % i]]) {
        p.insert(p.begin() + j - (a[i + 1][p[j]] != a[p[j]][p[j - 1]]), i + 1);
        goto skip;
      }
      p.pb(i + 1);
      skip:;
    }
    For(i, 1, n - 1) if (a[p[i - 1]][p[i]] != a[p[i]][p[(i + 1) % n]]) {
      rotate(p.begin(), p.begin() + i, p.end());
      break;
    }
    for (int u : p) cout << u << ' ';
    cout << '\n';
  }
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3776kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

3 1 2 
1 2 3 4 

result:

ok 2 cases.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

3
000
000
000
3
010
100
000
3
011
100
100
3
011
101
110

output:

1 2 3 
2 3 1 
2 3 1 
1 2 3 

result:

ok 4 cases.

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3696kb

input:

4
0000
0000
0000
0000
4
0000
0001
0000
0100
4
0100
1010
0100
0000
4
0111
1000
1000
1000
4
0010
0011
1101
0110
4
0111
1011
1100
1100
4
0111
1011
1101
1110
4
0000
0011
0101
0110
4
0101
1010
0100
1000
4
0011
0011
1100
1100
4
0010
0001
1000
0100

output:

1 2 3 4 
1 2 3 4 
2 3 1 4 
2 3 4 1 
2 3 4 1 
3 4 1 2 
1 2 3 4 
2 3 4 1 
4 2 3 1 
1 2 3 4 
2 4 3 1 

result:

wrong answer case #9: found 3 indices