提出 #15802059
ソースコード 拡げる
#include <iostream>
#include <vector>
using lint = long long;
constexpr int N = 200000;
std::vector<lint> vs(N, 0);
void input() { std::cin >> vs[0] >> vs[1]; }
int cnt = 0;
void query(char c, int i, int j, int k) {
std::cout << c << " " << i << " " << j << " " << k << "\n";
++cnt;
if (c == '+') {
vs[k] = vs[i] + vs[j];
} else if (c == '<') {
vs[k] = (vs[i] < vs[j]);
}
}
/* ----- several constants, functions ----- */
constexpr int A = 0, B = 1, S = 2;
constexpr int ZERO = 100, ONE = 101;
constexpr int K = 30, KB = 200;
void reset(int i) { query('+', ZERO, ZERO, i); }
void copy(int i, int j) { query('+', ZERO, i, j); }
void negate(int i) { query('<', i, ONE, i); }
void pow(int i, int k) {
while (k--) query('+', i, i, i);
}
/* ----- main routine ----- */
void init() {
query('+', A, B, 2);
query('<', ZERO, 2, ONE); // v[ZERO] = 0, v[ONE] = 1
reset(2);
query('+', ZERO, ONE, KB);
for (int k = 1; k <= K; ++k) {
query('+', KB + k - 1, KB + k - 1, KB + k);
// v[KB + k] = 2^k
}
}
void tobin(int xi, int l) {
const int SB = l + K + 1;
for (int k = K; k >= 0; --k) {
query('+', SB, KB + k, SB + 1);
query('<', xi, SB + 1, l + k);
negate(l + k); // v[l+k] = (sum + 2^k <= x)
copy(l + k, SB + 1);
pow(SB + 1, k);
query('+', SB, SB + 1, SB); // sum += (v[l+k] * 2^k)
}
}
void multiply(int xi, int yi, int zi, int l) {
for (int xk = 0; xk <= K; ++xk) {
for (int yk = 0; yk <= K; ++yk) {
query('+', xi + xk, yi + yk, l + 1);
query('<', ONE, l + 1, l + 1);
query('+', zi + xk + yk, l + 1, zi + xk + yk);
// v[zi+xk+yk] += x[xk] & y[yk]
}
}
for (int k = 0; k <= K * 2; ++k) {
pow(zi + k, k);
query('+', l, zi + k, l);
}
}
void solve() {
init();
constexpr int AB = 300, BB = 400, FB = 500;
tobin(A, AB);
tobin(B, BB);
multiply(AB, BB, FB, S);
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
std::cout << 6048 << "\n";
// input();
solve();
// std::cerr << "result: " << vs[2] << "\n";
// std::cerr << "counter: " << cnt << "\n";
return 0;
}
提出情報
ジャッジ結果
| セット名 |
Sample |
Subtask1 |
Subtask2 |
| 得点 / 配点 |
0 / 0 |
800 / 800 |
1000 / 1000 |
| 結果 |
|
|
|
| セット名 |
テストケース |
| Sample |
s1.txt |
| Subtask1 |
001.txt |
| Subtask2 |
101.txt, 102.txt, 103.txt, 104.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 001.txt |
AC |
9 ms |
4680 KiB |
| 101.txt |
AC |
8 ms |
4612 KiB |
| 102.txt |
AC |
7 ms |
4620 KiB |
| 103.txt |
AC |
8 ms |
4652 KiB |
| 104.txt |
AC |
7 ms |
4440 KiB |
| s1.txt |
AC |
12 ms |
4492 KiB |