QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#807823#7700. Split Decisionsucup-team3723#WA 13ms17716kbC++172.3kb2024-12-10 12:31:522024-12-10 12:31:54

Judging History

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

  • [2024-12-10 12:31:54]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:17716kb
  • [2024-12-10 12:31:52]
  • 提交

answer

#include <bits/stdc++.h>
#define dbg(x) cerr << #x << ':' << (x) << endl; 
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()

int main()
{
    int n;
    cin >> n;

    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];

    int sz = 26;

    vector<vector<int>> z_hash(s[0].size(),vector<int>(sz));
    mt19937 mt_random(0);
    for (int i = 0; i < s[0].size(); i++) {
        for (int j = 0; j < sz; j++) {
            z_hash[i][j] = mt_random();
        }
    }
    vector<vector<int>> h(s[0].size(), vector<int>(n));
    for (int i = 0; i < s[0].size()-1; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < s[0].size(); k++) {
                if (i == k || i+1 == k) continue;
                h[i][j] ^= z_hash[k][s[j][k]-'A'];
            }
        }
    }

    auto func = [](char a, char b){
        return (a-'A')*26 + (b-'A');
    };

    vector<vector<vector<int>>> v(s[0].size(), vector<vector<int>>(sz*sz, vector<int>(sz*sz)));
    for (int i = 0; i < s[0].size()-1; ++i) {
        
        for (int j = 0; j < n; ++j) {
            int tmp1 = func(s[j][i],s[j][i+1]);
            for (int k = j+1; k < n; ++k) {
                int tmp2 = func(s[k][i],s[k][i+1]);
                if (h[i][j] != h[i][k]) continue;
                if (tmp1 == tmp2) continue;
                if (tmp1 < tmp2) v[i][tmp1][tmp2]++;
                else v[i][tmp2][tmp1]++;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = 0; k < s[0].size()-1; k++) {
                int tmp1 = func(s[i][k],s[i][k+1]);
                int tmp2 = func(s[j][k],s[j][k+1]);
                if (h[k][i] != h[k][j]) continue;
                if (tmp1 == tmp2) continue;
                
                if (tmp1 < tmp2) {
                    if (v[k][tmp1][tmp2] == 1) {
                        ++ans;
                        break;
                    }
                }
                else {
                    if (v[k][tmp2][tmp1] == 1) {
                        ++ans;
                        break;
                    }
                }
            }
        }
    }

    cout << ans << endl;

}

詳細信息

Test #1:

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

input:

5
CELL
GULL
GUSH
HALL
HASH

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 13ms
memory: 17716kb

input:

1000
ABSALOM
ACRATIA
AKHOOND
ALIBAMU
AMUSIVE
AGONIZE
ACOCOTL
ACTINON
ABELITE
ADVISAL
ALBETAD
AMAKEBE
ANASAZI
AMUCHCO
ADDENDA
AMESITE
ALIENEE
ADRENIN
ACERATE
AKERITE
AMPELIS
ABABDEH
ALCIDAE
AGRANIA
ALASTER
AMERISM
AMILOUN
AMYGDAL
ALUNDUM
ACHOLIC
ALTHAEA
ACIDIFY
AMNESTY
ABBOTCY
AMBALAM
AMENITY
AEOLISM...

output:

797

result:

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