QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#689264#1965. Triok1nsom#WA 0ms3612kbC++231.4kb2024-10-30 16:05:332024-10-30 16:05:35

Judging History

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

  • [2024-10-30 16:05:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-10-30 16:05:33]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define endl '\n'
const int N = 2e3 + 5;
int n, a[N][5], cnt[N][20];

void solve()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        string s;
        cin >> s;
        for (int j = 1; j <= 4; j++)
            a[i][j] = s[j] - '0';
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
        {
            int st = 0;
            for (int k = 1; k <= 4; k++)
                if (a[i][k] == a[j][k])
                    st |= 1 << (k - 1);
            cnt[i][st]++;
        }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
        {
            int zt = 0;
            for (int k = 1; k <= 4; k++)
                if (a[i][k] == a[j][k])
                    zt |= 1 << (k - 1);
            ans += cnt[i][zt];
            for (int st = zt + 1; st <= 16; st++)
                if ((st & zt) == zt)
                {
                    if (__builtin_popcount(st ^ zt) & 1)
                        ans -= cnt[j][st];
                    else
                        ans += cnt[j][st];
                }
        }
    cout << ans / 3 << endl;
}

signed main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1234
2345
3456
4567

output:

4

result:

ok single line: '4'

Test #2:

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

input:

9
1299
2399
3499
4599
5699
6799
7899
8999
9199

output:

84

result:

ok single line: '84'

Test #3:

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

input:

9
1239
2349
3459
4569
5679
6789
7899
8919
9129

output:

108

result:

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