結果
問題 | No.469 区間加算と一致検索の問題 |
ユーザー |
![]() |
提出日時 | 2016-12-19 00:32:58 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 123 ms / 5,000 ms |
コード長 | 1,266 bytes |
コンパイル時間 | 1,207 ms |
コンパイル使用メモリ | 104,188 KB |
実行使用メモリ | 16,896 KB |
最終ジャッジ日時 | 2024-12-21 16:41:21 |
合計ジャッジ時間 | 5,525 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:44:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 44 | scanf("%d%d", &n, &q); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:53:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 53 | scanf(" %c", &c); | ~~~~~^~~~~~~~~~~ main.cpp:59:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 59 | scanf("%d%d%d", &l, &r, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#define _CRT_SECURE_NO_WARNINGS#include<sstream>#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<climits>#include<cmath>#include<string>#include<vector>#include<set>#include<map>#include<queue>#include<numeric>#include<functional>#include<algorithm>#include<bitset>#include<tuple>#include<unordered_set>#include<random>using namespace std;#define INF (1<<29)#define rep(i,n) for(int i=0;i<(int)(n);i++)#define all(v) v.begin(),v.end()#define uniq(v) v.erase(unique(all(v)),v.end())unsigned int xor128() {static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;unsigned int t = (x ^ (x << 11));x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}unsigned long long rhash[1000001];int main() {ios::sync_with_stdio(0);cin.tie(0);int n, q;scanf("%d%d", &n, &q);for (int i = 1; i <= n; i++) {rhash[i] = rhash[i - 1] + xor128();}unsigned long long cur = 0;map<unsigned long long, int> mp;mp[0] = 0;rep(i,q) {char c;scanf(" %c", &c);if (c == '?') {cout << mp[cur] << endl;}else {int l, r, k;scanf("%d%d%d", &l, &r, &k);cur += k * (rhash[r] - rhash[l]);auto it = mp.emplace(cur, i + 1);}}return 0;}