跳到正文

题解

AT_abc348_f [ABC348F] Oddly Similar tj

_colin1112_约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前

思路

根据题意模拟,n2n^2 搜索两个数列进行判断是否为相似序列即可。最后在 atcoder 上使用 C++23(clang++) 提交便跑得飞快。

Code

C++
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'

using namespace std;
const int E = 1e6 + 5;
ll n, m;
ll a[2005][2005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];
    ll ans = 0, cnt;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
        {
            cnt = 0;
            for (int k = 1; k <= m; k++)
                if (a[i][k] == a[j][k])
                    cnt++;
            ans += ((cnt & 1) == 1);
        }
    cout << ans;
    return 0;
}
原文