結果
| 問題 | No.469 区間加算と一致検索の問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-18 23:59:17 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,064 bytes |
| 記録 | |
| コンパイル時間 | 780 ms |
| コンパイル使用メモリ | 94,308 KB |
| 実行使用メモリ | 926,208 KB |
| 最終ジャッジ日時 | 2026-05-18 23:59:47 |
| 合計ジャッジ時間 | 8,508 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 20 MLE * 1 -- * 28 |
コンパイルメッセージ
main.cpp: In function 'std::string ToStr()':
main.cpp:15:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
15 | for (auto [pos, cnt] : cf) {
| ^
ソースコード
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
const int N = 1000010;
int n, q, idx;
map<int, int> cf; // 存非零
map<string, int> mm;
string ToStr() {
string ret = "";
for (auto [pos, cnt] : cf) {
if (cnt == 0) continue;
ret += (pos + '0');
ret += ',';
if (cnt < 0) ret += '-';
ret += (abs(cnt) + '0');
ret += ';';
}
return ret;
}
int main() {
// freopen("seq.in", "r", stdin);
// freopen("seq.out", "w", stdout);
scanf("%d%d", &n, &q);
string ss = ToStr();
if (!mm.count(ss)) mm[ss] = 0;
while (q--) {
char op;
scanf(" %c", &op);
if (op == '!') {
int l, r, k;
scanf("%d%d%d", &l, &r, &k);
cf[l] += k, cf[r] -= k;
while (cf.find(0) != cf.end()) cf.erase(cf.find(0));
string s = ToStr();
if (!mm.count(s)) mm[s] = ++idx;
} else {
string s = ToStr();
printf("%d\n", mm[s]);
}
}
return 0;
}