結果

問題 No.1820 NandShift
ユーザー Nachia
提出日時 2022-01-21 23:27:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,424 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 84,640 KB
最終ジャッジ日時 2025-01-27 14:33:08
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using i32 = int;
using u32 = unsigned int;
#define rep(i,n) for(int i=0; i<(n); i++)


bool is_piriodic(const string& s, int k){
    int n = s.size();
    for(int i=0; i<n; i++) if(s[i] != s[(i+k)%n]) return false;
    return true;
}



int main() {
    int N,M; cin >> N >> M;
    string X; cin >> X;
    vector<string> A(N);
    rep(i,N) cin >> A[i];

    vector<vector<int>> ans;

    auto query_shift = [&](int o, int i) -> void {
        ans.push_back({ 1, o, i });
    };
    auto query_nand = [&](int o, int a, int b) -> void {
        ans.push_back({ 2, o, a, b });
    };

    query_nand(0,0,0);

    reverse(X.begin(), X.end());

    int Z = 7001;
    query_nand(Z,Z,Z);
    query_shift(Z,Z);
    rep(i,M){
        if(X[i] == '1'){
            query_nand(0,0,Z);
            query_nand(0,0,0);
        }
        query_nand(Z,Z,Z);
        query_shift(Z,Z);
        query_nand(Z,Z,Z);
    }
    query_nand(0,0,0);

    cout << ans.size() << "\n";
    for(auto& a : ans){
        rep(i,a.size()){
            if(i) cout << " ";
            cout << a[i];
        }
        cout << "\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;
0