結果

問題 No.3211 NAND Oracle
ユーザー GOTKAKO
提出日時 2025-07-25 22:36:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,604 bytes
コンパイル時間 1,795 ms
コンパイル使用メモリ 203,128 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-07-25 22:36:32
合計ジャッジ時間 5,342 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

void check(vector<pair<int,int>> ope){
    auto f = [&](int a0,int a1) -> int {
        vector<int> A = {a0,a1};
        for(auto [p,q] : ope){
            if(A.at(p) == 1 && A.at(q) == 1) A.push_back(0);
            else A.push_back(1);
        }
        for(auto &a : A) cout << a << " "; cout << " ";
        return accumulate(A.begin(),A.end(),0);
    };
    cout << "00->" << f(0,0) << endl; 
    cout << "01->" << f(0,1) << endl; 
    cout << "10->" << f(1,0) << endl; 
    cout << "11->" << f(1,1) << endl; 
}

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

    int N,K; cin >> N >> K;
    K -= 2;
    if(N/2 > K){
        if(K+2 < 5) cout << "No\n";
        else{
            cout << "Yes\n";
            cout << "1 2\n";
            cout << "1 2\n";
            cout << "3 4\n";
            cout << "4 5\n";
            cout << "4 5\n";
            vector<pair<int,int>> ope = {{0,1},{0,1},{2,3},{3,4},{3,4}};
            N -= 5;
            while(N--) cout << "6 7\n",ope.push_back({5,6});
            //check(ope);
        }
    }else{
        cout << "Yes\n";
        vector<pair<int,int>> ope;
        {
            cout << "1 2\n"; N--;
            ope.push_back({0,1});
            if(N){
                cout << "1 2\n"; N--;
               ope.push_back({0,1});
            }    
        }
        while(N){
            cout << "3 4\n"; N--;
            ope.push_back({2,3});
            if(N == 0) break;
            cout << "1 2\n"; N--;
            ope.push_back({0,1});
        }
        //check(ope);
    } 
}
0