今天的DIV3的T3 45分求调
  • 板块题目总版
  • 楼主lzy20091001
  • 当前回复5
  • 已保存回复5
  • 发布时间2023/8/26 22:04
  • 上次更新2023/11/3 01:00:19
查看原帖
今天的DIV3的T3 45分求调
932039
lzy20091001楼主2023/8/26 22:04

额,讨论版进不去,就在这里发了。

#include <iostream>
using namespace std;

int n, m, q, k, a[3][500005], cnt[3][500005];
long long ans;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> n >> m >> q >> k;
    while (q--)
    {
        int op, x;
        cin >> op >> x;
        a[op][x] = (a[op][x] + 1) % k;
    }
    for (int i = 1; i <= n; i++)
        cnt[1][a[1][i]]++;
    for (int j = 1; j <= m; j++)
        cnt[2][a[2][j]]++;
    ans = n * m;
    ans -= cnt[1][0] * cnt[2][0];
    for (int i = 1; i <= k; i++)
        ans -= cnt[1][i] * cnt[2][k - i];
    cout << ans << "\n";
    return 0;
}
                   
2023/8/26 22:04
加载中...