結果
| 問題 |
No.1820 NandShift
|
| コンテスト | |
| ユーザー |
259_Momone
|
| 提出日時 | 2022-01-21 23:01:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 976 bytes |
| コンパイル時間 | 2,294 ms |
| コンパイル使用メモリ | 201,092 KB |
| 最終ジャッジ日時 | 2025-01-27 14:21:16 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
int main(){
using namespace std;
unsigned long N, M;
cin >> N >> M;
string X;
cin >> X;
X.push_back('1');
vector<unsigned long> dif;
for(unsigned long i{}; i < M; ++i)if(X[M - i] != X[M - i - 1])dif.emplace_back(i);
vector<tuple<unsigned long, unsigned long, unsigned long, unsigned long>> ops;
const auto operation{[&N, &ops](unsigned long t, unsigned long x, unsigned long y, unsigned long z){
ops.emplace_back(t, x ? x + N : x, y ? y + N : y, z ? z + N : z);
}};
operation(2, 0, 0, 0);
if(!empty(dif)){
for(unsigned long i{}; i < dif.back(); ++i)operation(1, i + 1, i, 0);
reverse(begin(dif), end(dif));
for(const auto& i : dif)operation(2, 0, 0, i);
}
cout << size(ops) << endl;
for(const auto& [t, x, y, z] : ops)if(t == 1)cout << t << " " << x << " " << y << endl;
else cout << t << " " << x << " " << y << " " << z << endl;
return 0;
}
259_Momone