結果
問題 | No.255 Splarrraaay スプラーレェーーイ |
ユーザー | Kmcode1 |
提出日時 | 2015-07-24 23:16:53 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,092 bytes |
コンパイル時間 | 1,165 ms |
コンパイル使用メモリ | 117,120 KB |
実行使用メモリ | 219,848 KB |
最終ジャッジ日時 | 2024-07-08 13:44:41 |
合計ジャッジ時間 | 8,517 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 68 ms
209,968 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:222:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 222 | scanf("%lld", &n); | ~~~~~^~~~~~~~~~~~ main.cpp:224:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 224 | scanf("%d", &qq); | ~~~~~^~~~~~~~~~~ main.cpp: In constructor ‘st::st()’: main.cpp:109:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 109 | scanf("%d%lld%lld", &ty, &ll, &rr); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cctype> #include<cstdlib> #include<algorithm> #include<bitset> #include<vector> #include<list> #include<deque> #include<queue> #include<map> #include<set> #include<stack> #include<cmath> #include<sstream> #include<fstream> #include<iomanip> #include<ctime> #include<complex> #include<functional> #include<climits> #include<cassert> #include<iterator> #include<unordered_map> #include<stdint.h> #include<quadmath.h> using namespace std; #define MAX 200002 string pluss(string a, string b, bool flag = false){ if (!flag){ reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); } if (a.size() > b.size()){ swap(a, b); } string ans; ans.clear(); long long int want = 0; for (int i = 0; i < a.size(); i++){ long long int val = a[i] - '0'; val += b[i] - '0'; val += want; want = val / 10LL; val %= 10LL; ans.push_back(val + '0'); } for (int j = a.size(); j < b.size(); j++){ long long int val = 0; val += b[j] - '0'; val += want; want = val / 10LL; val %= 10LL; ans.push_back(val + '0'); } while (want){ ans.push_back(want % 10 + '0'); want /= 10; } if (!flag){ reverse(ans.begin(), ans.end()); } return ans; } string mult(string a, string b, bool flag = false){ if (!flag){ reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); } string ans = "0"; string pas; string kari; pas.clear(); for (int i = 0; i < b.size(); i++){ long long int bb = b[i] - '0'; long long int tmp = 0; kari = pas; for (int j = 0; j < a.size(); j++){ long long int val = (long long int)(a[j] - '0')*bb; val += tmp; tmp = val / 10LL; val %= 10LL; kari.push_back(val + '0'); } while (tmp){ kari.push_back((tmp % 10LL) + '0'); tmp /= 10LL; } ans = pluss(ans, kari, true); //end pas.push_back('0'); } if (!flag){ reverse(ans.begin(), ans.end()); } return ans; } long long n; vector<long long int> v; long long int MOD = 1000000000000000009LL; struct st{ int ty; long long int l; long long int r; st(){ long long int ll, rr; scanf("%d%lld%lld", &ty, &ll, &rr); l = ll; r = rr; } }; vector<st> vv; struct s{ string AREA; __int128 area = 0; int col = -1; __int128 l=-1; __int128 r=-1; __int128 ar[5]; s(){ for (int i = 0; i < 5; i++){ ar[i] = 0; } } }; #define MAXX 300012 s seg[MAXX * 4]; string conv(long long int num){ string r; r.clear(); while (num){ r.push_back(num % 10LL); num /= 10LL; } reverse(r.begin(), r.end()); return r; } void init(int b, int l, int r){ seg[b].l = l; seg[b].r = r; seg[b].area = v[r] - v[l]; seg[b].AREA = conv(seg[b].area); if (l + 1 == r){ return; } init(b * 2 + 1, l, (l + r) >> 1); init(b * 2 + 2, (l + r) >> 1, r); } void chang(int b, int x){ for (int i = 0; i < 5; i++){ if (i == x){ seg[b].ar[i] += seg[b].area; } else{ seg[b].ar[i] = 0; } } if (seg[b].l + 1 != seg[b].r){ seg[b * 2 + 1].col = x; seg[b * 2 + 2].col = x; } seg[b].col = -1; } void update(int b){ if (seg[b].col== -1){ return; } chang(b, seg[b].col); seg[b].col = -1; return; } inline void add(int b, int l, int r, int ll, int rr, int x){ update(b); if (rr <= l || r <= ll){ return; } if (ll <= l&&r <= rr){ chang(b, x); return; } add(b * 2 + 1, l, (l + r) >> 1, ll, rr, x); add(b * 2 + 2, (l + r) >> 1, r, ll, rr, x); for (int i = 0; i < 5; i++){ seg[b].ar[i] = seg[b * 2 + 1].ar[i] + seg[b * 2 + 2].ar[i]; } } __int128 sum[5]; inline void q(int b, int l, int r, int ll, int rr){ update(b); if (rr <= l || r <= ll){ return; } if (ll <= l&&r <= rr){ for (int i = 0; i < 5; i++){ sum[i] += seg[b].ar[i]; } return; } q(b * 2 + 1, l, (l + r) >> 1, ll, rr); q(b * 2 + 2, (l + r) >> 1, r, ll, rr); } __int128 b[5]; void output(){ for (int i = 0; i < 5; i++){ sum[i] = 0; } q(0, 0, v.size() - 1, 0, v.size() - 1); for (int i = 0; i < 5; i++){ if (i){ printf(" "); } __int128 ans = sum[i] + b[i]; ans %= MOD; unsigned long long int outt = ans; printf("%lld",outt); } puts(""); } int main(){ scanf("%lld", &n); int qq; scanf("%d", &qq); for (int i = 0; i < qq; i++){ vv.push_back(st()); v.push_back(vv.back().l); v.push_back(vv.back().r+1LL); } v.push_back(n); v.push_back(0); sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); init(0, 0, v.size()-1); for (int i = 0; i < qq; i++){ int ind = lower_bound(v.begin(), v.end(), vv[i].l) - v.begin(); int ind2 = lower_bound(v.begin(), v.end(), vv[i].r + 1LL) - v.begin(); if (vv[i].ty == 0){ for (int i = 0; i < 5; i++){ sum[i] = 0; } q(0, 0, v.size() - 1, ind, ind2); int ind = 0; __int128 val = -1LL; __int128 S = 0; for (int i = 0; i < 5; i++){ if (val < sum[i]){ val = sum[i]; ind = i; } S += sum[i]; } int countt = 0; for (int i = 0; i < 5; i++){ if (val == sum[i]){ countt++; } } if (countt == 1){ b[ind] += val; } } else{ add(0, 0, v.size() - 1, ind, ind2, vv[i].ty - 1); } //output(); } output(); return 0; }