QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#387956#3168. Letter Wheelsohiostatescarlet#WA 99ms3876kbC++171.1kb2024-04-13 07:43:322024-04-13 07:43:32

Judging History

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

  • [2024-04-13 07:43:32]
  • 评测
  • 测评结果:WA
  • 用时:99ms
  • 内存:3876kb
  • [2024-04-13 07:43:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define L long long
#ifdef LOCAL
#define dbg(x) cerr << '[' << #x << " = " << (x) << "]\n";
#else
#define dbg(x)
#endif
// g++ -std=c++17 -O2 -DLOCAL -o a a.cpp

int main() {
    cin.tie(0)->sync_with_stdio(0);
    vector<string> s(3);
    for (auto &i : s) cin >> i;
    int n = s[0].size();
    int ans = 1e9;
    for (int zz = 0; zz < 3; zz++) {
        unordered_map<string, int> cyc;
        for (int i = 0; i < n; i++) {
            string c = s[2].substr(i) + s[2].substr(0, i);
            int d = min(i, n - i);
            cyc[c] = d;
        }
        for (int i = 0; i < n; i++) {
            string newb = s[1].substr(i) + s[1].substr(0, i);
            string c = string(n, 'A' ^ 'B' ^ 'C');
            for (int j = 0; j < n; j++) {
                c[j] ^= newb[j] ^ s[0][j];
            }
            if (cyc.count(c)) {
                int d = cyc[c];
                ans = min(ans, min(i, n - i) + d);
            }
        }
        swap(s[0], s[2]);
        swap(s[1], s[2]);
    }
    if (ans > 1e8) cout << "-1\n";
    else cout << ans << '\n';
}
// AAB
// BCC
// CCA

详细

Test #1:

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

input:

ABC
ABC
ABC

output:

2

result:

ok single line: '2'

Test #2:

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

input:

ABBBAAAA
BBBCCCBB
CCCCAAAC

output:

3

result:

ok single line: '3'

Test #3:

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

input:

AABB
BBCC
ACAC

output:

-1

result:

ok single line: '-1'

Test #4:

score: -100
Wrong Answer
time: 99ms
memory: 3664kb

input:

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

1

result:

wrong answer 1st lines differ - expected: '0', found: '1'