結果
| 問題 |
No.1589 Bit Vector
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-09 15:00:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,054 bytes |
| コンパイル時間 | 2,171 ms |
| コンパイル使用メモリ | 183,280 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-01 14:00:19 |
| 合計ジャッジ時間 | 4,057 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 35 |
ソースコード
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int N, K;
void input_NK(void){
cin >> N >> K;
}
void sort_xy(int x, int y, ostringstream& oss, int& op){
oss << "UPD " << N << " 0" << endl;
oss << "XOR " << N << " " << x << " " << N << endl;
oss << "AND " << x << " " << x << " " << y << endl;
oss << "XOR " << y << " " << y << " " << N << endl;
oss << "XOR " << y << " " << x << " " << y << endl;
op += 5;
}
void sort_prefix(ostringstream& oss, int& op){
string ret = "";
for (int i = 0; i < N; ++i)
for (int y = N - 1; y > i; --y)
sort_xy(y - 1, y, oss, op);
}
string solve(int& op){
ostringstream oss;
op = 0;
sort_prefix(oss, op);
oss << "UPD " << N << " 1" << endl;
for (int i = N - 1; i >= N - K; --i)
oss << "AND " << N << " " << i << " " << N << endl;
op += K + 1;
return oss.str();
}
int main(void){
input_NK();
int op;
string ans = solve(op);
cout << op << endl << ans;
return 0;
}