結果
問題 | No.1649 Manhattan Square |
ユーザー | rk427454171 |
提出日時 | 2021-08-13 23:09:05 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 252 ms / 3,000 ms |
コード長 | 2,625 bytes |
コンパイル時間 | 1,938 ms |
コンパイル使用メモリ | 177,780 KB |
実行使用メモリ | 10,500 KB |
最終ジャッジ日時 | 2024-04-14 20:11:17 |
合計ジャッジ時間 | 12,840 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 5 ms
6,940 KB |
testcase_03 | AC | 5 ms
6,944 KB |
testcase_04 | AC | 5 ms
6,944 KB |
testcase_05 | AC | 4 ms
6,940 KB |
testcase_06 | AC | 5 ms
6,944 KB |
testcase_07 | AC | 239 ms
10,364 KB |
testcase_08 | AC | 243 ms
10,236 KB |
testcase_09 | AC | 252 ms
10,364 KB |
testcase_10 | AC | 238 ms
10,236 KB |
testcase_11 | AC | 246 ms
10,240 KB |
testcase_12 | AC | 212 ms
7,296 KB |
testcase_13 | AC | 228 ms
8,704 KB |
testcase_14 | AC | 219 ms
7,808 KB |
testcase_15 | AC | 223 ms
8,192 KB |
testcase_16 | AC | 207 ms
6,940 KB |
testcase_17 | AC | 209 ms
6,944 KB |
testcase_18 | AC | 199 ms
6,940 KB |
testcase_19 | AC | 218 ms
8,064 KB |
testcase_20 | AC | 211 ms
7,164 KB |
testcase_21 | AC | 233 ms
8,704 KB |
testcase_22 | AC | 243 ms
10,372 KB |
testcase_23 | AC | 243 ms
10,492 KB |
testcase_24 | AC | 234 ms
10,364 KB |
testcase_25 | AC | 231 ms
10,368 KB |
testcase_26 | AC | 231 ms
10,496 KB |
testcase_27 | AC | 246 ms
10,364 KB |
testcase_28 | AC | 233 ms
10,368 KB |
testcase_29 | AC | 239 ms
10,368 KB |
testcase_30 | AC | 232 ms
10,240 KB |
testcase_31 | AC | 240 ms
10,492 KB |
testcase_32 | AC | 240 ms
10,368 KB |
testcase_33 | AC | 235 ms
10,244 KB |
testcase_34 | AC | 230 ms
10,500 KB |
testcase_35 | AC | 237 ms
10,368 KB |
testcase_36 | AC | 250 ms
10,364 KB |
testcase_37 | AC | 242 ms
10,496 KB |
testcase_38 | AC | 242 ms
10,372 KB |
testcase_39 | AC | 252 ms
10,364 KB |
testcase_40 | AC | 232 ms
10,240 KB |
testcase_41 | AC | 247 ms
10,240 KB |
testcase_42 | AC | 193 ms
10,364 KB |
testcase_43 | AC | 2 ms
6,944 KB |
testcase_44 | AC | 2 ms
6,940 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:62:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 62 | for(auto &[x, y] : arr) | ^ main.cpp:66:25: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 66 | for(const auto &[x, y] : arr) { | ^
ソースコード
/* -------------- | / | | / | | / | * |/ | | ------ * | | | | / \ | | |\ | | | |\ | \ | | | \ | | | | \ | \ | | | \ | | \ / \ | V | | \ \__/| ----- \ | */ #include <bits/stdc++.h> using namespace std; #define debug(x) cerr << "\e[1;31m" << #x << " = " << (x) << "\e[0m\n" #define print(x) emilia_mata_tenshi(#x, begin(x), end(x)) template<typename T> void emilia_mata_tenshi(const char *s, T l, T r) { cerr << "\e[1;33m" << s << " = ["; while(l != r) { cerr << *l; cerr << (++l == r ? ']' : ','); } cerr << "\e[0m\n"; } #define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL); using ll = int64_t; using ull = uint64_t; using ld = long double; using uint = uint32_t; const double EPS = 1e-8; const int INF = 0x3F3F3F3F; const ll LINF = 4611686018427387903; const int MOD = 1e9+7; /*--------------------------------------------------------------------------------------*/ const int mod = 998244353, N = 2e5 + 25; struct fenwicktree { int arr[N]; void edt(int p, ll v) { v %= mod; for(; p < N; p += p & -p) arr[p] = (arr[p] + v) % mod; } ll que(int l, int r) { ll res = 0; for(; r; r -= r & -r) res = (res + arr[r]) % mod; for(l--; l; l -= l & -l) res = (res - arr[l] + mod) % mod; return res; } } cnt, sum, sum2, rcnt, rsum, rsum2; signed main() { EmiliaMyWife int n; cin >> n; vector<pair<int, int>> arr(n); vector<int> v(1, -10); for(int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second, v.push_back(arr[i].second); sort(arr.begin(), arr.end()); sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); for(auto &[x, y] : arr) y = lower_bound(v.begin(), v.end(), y) - v.begin(); ll ans = 0; for(const auto &[x, y] : arr) { ll t = (x + v[y]) % mod; ans = (ans + t * t % mod * cnt.que(1, y) + sum.que(1, y)) % mod; ans = (ans - 2 * t * sum2.que(1, y) % mod + mod) % mod; cnt.edt(y, 1); sum.edt(y, t * t % mod); sum2.edt(y, t); //debug(ans); t = (x - v[y] + mod) % mod; ans = (ans + t * t % mod * rcnt.que(y + 1, n) + rsum.que(y + 1, n)) % mod; ans = (ans - 2 * t * rsum2.que(y + 1, n) % mod + mod) % mod; rcnt.edt(y, 1); rsum.edt(y, t * t % mod); rsum2.edt(y, t); //debug(ans); } cout << (ans + mod) % mod << '\n'; }