結果
| 問題 | 
                            No.2142 Segment Zero
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Nachia
                         | 
                    
| 提出日時 | 2022-12-02 21:40:00 | 
| 言語 | C++17(gcc12)  (gcc 12.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 272 ms / 2,000 ms | 
| コード長 | 712 bytes | 
| コンパイル時間 | 2,504 ms | 
| コンパイル使用メモリ | 117,592 KB | 
| 最終ジャッジ日時 | 2025-02-09 03:38:51 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 35 | 
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;
int main(){
    i64 N, K; cin >> N >> K;
    vector<i64> S(N+1);
    rep(i,N) S[i+1] = S[i] + (i+1);
    set<i64> Q(S.begin(), S.end());
    int ans = 2;
    rep(i,N+1) if(Q.count(K - (S[N] - S[i]))) ans = 1;
    cout << ans << '\n';
    return 0;
}
struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
            
            
            
        
            
Nachia