Submission #2599987
Source Code Expand
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cassert> #include <iostream> #include <sstream> #include <vector> #include <queue> #include <set> #include <map> #include <utility> #include <numeric> #include <algorithm> #include <bitset> #include <complex> #include <array> #include <list> #include <stack> #include <valarray> using namespace std; typedef unsigned uint; typedef long long Int; typedef unsigned long long UInt; const int INF = 1001001001; const Int INFLL = 1001001001001001001LL; template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template<typename T> void chmin(T& a, T b) { if (a > b) a = b; } template<typename T> void chmax(T& a, T b) { if (a < b) a = b; } int in() { int x; scanf("%d", &x); return x; } double fin() { double x; scanf("%lf", &x); return x; } Int lin() { Int x; scanf("%lld", &x); return x; } Int Y, W, N, M, D, A[100050], B[100050], C[100050]; vector<Int> Bs[100050]; map<Int, int> MP; Int res = 0; inline Int prv(Int d) { auto it = MP.lower_bound(d); return (--it)->first; } inline Int nxt(Int d) { return MP.upper_bound(d)->first; } void add(Int d) { ++MP[d]; if (MP[d] > 1) return; Int pr = prv(d); Int nx = nxt(d); if (nx - pr <= D + 1) return; ++res; if (nx - d <= D + 1) res += (nx - d - 1); if (d - pr <= D + 1) res += (d - pr - 1); } void rmv(Int d) { --MP[d]; if (MP[d] > 0) return; Int pr = prv(d); Int nx = nxt(d); MP.erase(d); if (nx - pr <= D + 1) return; --res; if (nx - d <= D + 1) res -= (nx - d - 1); if (d - pr <= D + 1) res -= (d - pr - 1); } int main() { Y = lin(); W = lin(); N = lin(); M = lin(); D = lin(); for (int i = 0; i < N; ++i) { A[i] = lin() - 1; } for (int i = 0; i < M; ++i) { B[i] = lin() - 1; C[i] = lin() - 1; Bs[C[i]].push_back(B[i]); } MP[-INFLL] = 1; MP[INFLL] = 1; for (int i = 0; i < N; ++i) { add(A[i]); } for (int i = 0; i < M; ++i) { add(B[i] * W + C[i]); } for (int off = 0; off < W; ++off) { printf("%lld\n", res); for (int i = 0; i < N; ++i) { rmv(A[i] + off); add(A[i] + off + 1); } for (const Int b : Bs[off]) { rmv(b * W + off); add((b + 1) * W + off); } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - 祝日 |
User | japlj |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 2422 Byte |
Status | AC |
Exec Time | 2432 ms |
Memory | 14336 KB |
Compile Error
./Main.cpp: In function ‘int in()’: ./Main.cpp:34:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int in() { int x; scanf("%d", &x); return x; } ^ ./Main.cpp: In function ‘double fin()’: ./Main.cpp:35:42: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] double fin() { double x; scanf("%lf", &x); return x; } ^ ./Main.cpp: In function ‘Int lin()’: ./Main.cpp:36:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] Int lin() { Int x; scanf("%lld", &x); return x; } ^
Judge Result
Set Name | Sample | Subtask1 | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | 100 / 100 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
Subtask1 | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, sample-01.txt, sample-02.txt |
All | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt, 02-17.txt, 02-18.txt, 02-19.txt, 02-20.txt, 02-21.txt, 02-22.txt, 02-23.txt, 02-24.txt, 02-25.txt, 02-26.txt, 02-27.txt, 02-28.txt, 02-29.txt, 02-30.txt, 02-31.txt, 02-32.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 270 ms | 14208 KB |
01-02.txt | AC | 252 ms | 13312 KB |
01-03.txt | AC | 122 ms | 11392 KB |
01-04.txt | AC | 41 ms | 6784 KB |
01-05.txt | AC | 221 ms | 11904 KB |
01-06.txt | AC | 213 ms | 11520 KB |
01-07.txt | AC | 201 ms | 11336 KB |
01-08.txt | AC | 30 ms | 6656 KB |
01-09.txt | AC | 232 ms | 12928 KB |
01-10.txt | AC | 32 ms | 6272 KB |
01-11.txt | AC | 156 ms | 13184 KB |
01-12.txt | AC | 173 ms | 12800 KB |
01-13.txt | AC | 179 ms | 13184 KB |
01-14.txt | AC | 67 ms | 8192 KB |
01-15.txt | AC | 219 ms | 12288 KB |
01-16.txt | AC | 6 ms | 4352 KB |
01-17.txt | AC | 46 ms | 6528 KB |
01-18.txt | AC | 235 ms | 11648 KB |
01-19.txt | AC | 230 ms | 14208 KB |
01-20.txt | AC | 221 ms | 13440 KB |
02-01.txt | AC | 2280 ms | 14208 KB |
02-02.txt | AC | 751 ms | 12416 KB |
02-03.txt | AC | 867 ms | 13312 KB |
02-04.txt | AC | 1268 ms | 13568 KB |
02-05.txt | AC | 2147 ms | 14080 KB |
02-06.txt | AC | 1142 ms | 12544 KB |
02-07.txt | AC | 202 ms | 11356 KB |
02-08.txt | AC | 196 ms | 5376 KB |
02-09.txt | AC | 2152 ms | 13184 KB |
02-10.txt | AC | 131 ms | 5888 KB |
02-11.txt | AC | 2148 ms | 13824 KB |
02-12.txt | AC | 576 ms | 12544 KB |
02-13.txt | AC | 864 ms | 12160 KB |
02-14.txt | AC | 167 ms | 5504 KB |
02-15.txt | AC | 600 ms | 12160 KB |
02-16.txt | AC | 49 ms | 4352 KB |
02-17.txt | AC | 67 ms | 6528 KB |
02-18.txt | AC | 288 ms | 11648 KB |
02-19.txt | AC | 2131 ms | 14208 KB |
02-20.txt | AC | 202 ms | 11380 KB |
02-21.txt | AC | 452 ms | 5120 KB |
02-22.txt | AC | 4 ms | 4352 KB |
02-23.txt | AC | 2432 ms | 14336 KB |
02-24.txt | AC | 1319 ms | 12544 KB |
02-25.txt | AC | 1350 ms | 12288 KB |
02-26.txt | AC | 4 ms | 4352 KB |
02-27.txt | AC | 113 ms | 4480 KB |
02-28.txt | AC | 514 ms | 4736 KB |
02-29.txt | AC | 187 ms | 11392 KB |
02-30.txt | AC | 191 ms | 11520 KB |
02-31.txt | AC | 196 ms | 11520 KB |
02-32.txt | AC | 267 ms | 4608 KB |
sample-01.txt | AC | 3 ms | 4352 KB |
sample-02.txt | AC | 3 ms | 4352 KB |
sample-03.txt | AC | 3 ms | 4352 KB |
sample-04.txt | AC | 3 ms | 4352 KB |