結果
| 問題 | 
                            No.2517 Right Triangles on Circle
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-10-27 23:04:08 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 573 bytes | 
| コンパイル時間 | 1,631 ms | 
| コンパイル使用メモリ | 199,524 KB | 
| 最終ジャッジ日時 | 2025-02-17 15:47:22 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 26 WA * 3 | 
ソースコード
#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++;
        } else {
            ans += cnt;
        }
    }
    cout << ans << "\n";
    return 0;
}