結果
問題 |
No.3278 Avoid Division
|
ユーザー |
![]() |
提出日時 | 2025-09-19 22:40:50 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,645 bytes |
コンパイル時間 | 2,964 ms |
コンパイル使用メモリ | 284,236 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-19 22:40:57 |
合計ジャッジ時間 | 6,267 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 16 WA * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; } bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<string> ans; auto f = [&] (string s, int a, int b, int c) -> string { auto g = [&] (int i) -> string { return i < 0 ? "A[" + to_string(-i) + "]" : string(1, i); }; return s + " " + g(a) + " " + g(b) + " " + g(c); }; int di = -1; bool fn2 = false; for (int i = 1; i <= N; i++) { char op; int val; cin >> op >> val; if (op == '+') { if (di == -1) { ans.push_back(f("add", 'a', 'a', -i)); } else if (!fn2) { ans.push_back(f("mul", 'b', -di, -i)); ans.push_back(f("add", 'a', 'a', 'b')); } else { ans.push_back(f("mul", 'b', 'd', -i)); ans.push_back(f("add", 'a', 'a', 'b')); } } else if (op == '*') { ans.push_back(f("mul", 'a', 'a', -i)); } else { if (di == -1) { di = i; } else { if (!fn2) { fn2 = true; ans.push_back(f("mul", 'd', -di, -i)); } else { ans.push_back(f("mul", 'd', 'd', -i)); } } } } ans.push_back(f("div", 'a', 'a', 'd')); cout << ans.size() << '\n'; for (auto s : ans) cout << s << '\n'; }