結果

問題 No.2517 Right Triangles on Circle
ユーザー take000
提出日時 2023-10-27 22:06:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 532 bytes
コンパイル時間 2,002 ms
コンパイル使用メモリ 199,016 KB
最終ジャッジ日時 2025-02-17 15:04:34
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, N) cin >> A[i], A[i] *= 2;

    ll ans = 0, cnt = 0;
    set<int> st;
    rep(i, N) {
        st.insert(A[i]);

        int rev = (A[i] + M) % (2 * M);
        if (st.find(rev) != st.end()) {
            ans += i - 1 + cnt;
            cnt++;
        }
    }
    cout << ans << "\n";

    return 0;
}
0