Submission #22360

# Submission time Handle Problem Language Result Execution time Memory
22360 2017-04-30T04:12:24 Z AcornCkiGs14004Team(#953, gs14004, cki86201, dotorya) Donut-shaped Enclosure (KRIII5_DE) C++14
2 / 7
1500 ms 97776 KB
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 1034567890123456789ll;
const db PI = acos(-1);
const db ERR = 1E-11;

class Node {
public:
	ll mx;
	ll v;
	Node() {
		mx = 0, v = 0;
	}
};

Node indt[1200000];
void update(int st, int en, int S, int E, int n, ll v) {
	if (st == S && en == E) {
		indt[n].mx += v;
		indt[n].v += v;
		return;
	}

	int M = (S + E) / 2;

	if (indt[n].v) {
		indt[2 * n].mx += indt[n].v;
		indt[2 * n].v += indt[n].v;
		indt[2 * n + 1].mx += indt[n].v;
		indt[2 * n + 1].v += indt[n].v;
		indt[n].v = 0;
	}

	if (en <= M) update(st, en, S, M, 2 * n, v);
	else if (st > M) update(st, en, M + 1, E, 2 * n + 1, v);
	else {
		update(st, M, S, M, 2 * n, v);
		update(M + 1, en, M + 1, E, 2 * n + 1, v);
	}
	indt[n].mx = max(indt[2 * n].mx, indt[2 * n + 1].mx);
}

vector <pair<pll, pll>> Vq;

map <ll, int> Mx;
map <ll, int> My;

ll Qu[100050][3];
int main() {
	int N, i;
	ll L, R;
	ll t1, t2, t3;
	scanf("%d %lld %lld", &N, &L, &R);
	for(i = 1; i <= N; i++) {
		scanf("%lld %lld %lld", &t1, &t2, &t3);
		Qu[i][0] = t1, Qu[i][1] = t2, Qu[i][2] = t3;

		Mx[t1 - R] = 0;
		Mx[t1 + R] = 0;
		Mx[t1 - L] = 0;
		Mx[t1 + L] = 0;

		My[t2 - R] = 0;
		My[t2 + R] = 0;
		My[t2 - L] = 0;
		My[t2 + L] = 0;
	}
	i = 0;
	for (auto &it : Mx) it.second = ++i;
	i = 0;
	for (auto &it : My) it.second = ++i;

	for (i = 1; i <= N; i++) {
		ll t1 = Qu[i][0], t2 = Qu[i][1], t3 = Qu[i][2];

		int sx = Mx[t1 - R];
		int ex = Mx[t1 + R];
		int sy = My[t2 - R];
		int ey = My[t2 + R];
		Vq.emplace_back(pll(sx, t3), pll(sy, ey));
		Vq.emplace_back(pll(ex + 1, -t3), pll(sy, ey));

		sx = Mx[t1 - L] + 1;
		ex = Mx[t1 + L] - 1;
		sy = My[t2 - L] + 1;
		ey = My[t2 + L] - 1;
		if (sx <= ex && sy <= ey) {
			Vq.emplace_back(pll(sx, -t3), pll(sy, ey));
			Vq.emplace_back(pll(ex + 1, t3), pll(sy, ey));
		}
	}
	sort(all(Vq));

	ll ans = 0;
	for (i = 0; i < Vq.size(); i++) {
		int sy = Vq[i].second.first;
		int ey = Vq[i].second.second;
		ll v = Vq[i].first.second;
		update(sy, ey, 1, IT_MAX, 1, v);
		
		if (i + 1 == Vq.size() || Vq[i].first.first != Vq[i + 1].first.first) ans = max(ans, indt[1].mx);
	}
	return !printf("%lld\n", ans);
}

Compilation message

DE.cpp:22:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 ^
DE.cpp:23:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/STACK:336777216")
 ^
DE.cpp: In function 'int main()':
DE.cpp:140:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < Vq.size(); i++) {
                ^
DE.cpp:146:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (i + 1 == Vq.size() || Vq[i].first.first != Vq[i + 1].first.first) ans = max(ans, indt[1].mx);
             ^
DE.cpp:98:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %lld %lld", &N, &L, &R);
                                   ^
DE.cpp:100:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld", &t1, &t2, &t3);
                                         ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 23120 KB Output is correct
2 Correct 6 ms 23120 KB Output is correct
3 Correct 0 ms 23120 KB Output is correct
4 Correct 3 ms 23120 KB Output is correct
5 Correct 0 ms 23252 KB Output is correct
6 Correct 9 ms 23252 KB Output is correct
7 Correct 6 ms 23392 KB Output is correct
8 Correct 6 ms 23388 KB Output is correct
9 Correct 6 ms 23528 KB Output is correct
10 Correct 3 ms 23560 KB Output is correct
11 Correct 6 ms 23552 KB Output is correct
12 Correct 6 ms 23572 KB Output is correct
13 Correct 3 ms 23528 KB Output is correct
14 Correct 9 ms 23536 KB Output is correct
15 Correct 9 ms 23540 KB Output is correct
16 Correct 6 ms 23556 KB Output is correct
17 Correct 3 ms 23528 KB Output is correct
18 Correct 3 ms 23660 KB Output is correct
19 Correct 9 ms 23540 KB Output is correct
20 Correct 6 ms 23516 KB Output is correct
21 Correct 3 ms 23548 KB Output is correct
22 Correct 6 ms 23556 KB Output is correct
23 Correct 3 ms 23552 KB Output is correct
24 Correct 3 ms 23568 KB Output is correct
25 Correct 6 ms 23556 KB Output is correct
26 Correct 6 ms 23572 KB Output is correct
27 Correct 13 ms 23568 KB Output is correct
28 Correct 13 ms 23544 KB Output is correct
29 Correct 3 ms 23528 KB Output is correct
30 Correct 9 ms 23532 KB Output is correct
31 Correct 6 ms 23516 KB Output is correct
32 Correct 6 ms 23516 KB Output is correct
33 Correct 3 ms 23516 KB Output is correct
34 Correct 3 ms 23520 KB Output is correct
35 Correct 3 ms 23544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 23120 KB Output is correct
2 Correct 6 ms 23120 KB Output is correct
3 Correct 0 ms 23120 KB Output is correct
4 Correct 3 ms 23120 KB Output is correct
5 Correct 0 ms 23252 KB Output is correct
6 Correct 9 ms 23252 KB Output is correct
7 Correct 6 ms 23392 KB Output is correct
8 Correct 6 ms 23388 KB Output is correct
9 Correct 6 ms 23528 KB Output is correct
10 Correct 3 ms 23560 KB Output is correct
11 Correct 6 ms 23552 KB Output is correct
12 Correct 6 ms 23572 KB Output is correct
13 Correct 3 ms 23528 KB Output is correct
14 Correct 9 ms 23536 KB Output is correct
15 Correct 9 ms 23540 KB Output is correct
16 Correct 6 ms 23556 KB Output is correct
17 Correct 3 ms 23528 KB Output is correct
18 Correct 3 ms 23660 KB Output is correct
19 Correct 9 ms 23540 KB Output is correct
20 Correct 6 ms 23516 KB Output is correct
21 Correct 3 ms 23548 KB Output is correct
22 Correct 6 ms 23556 KB Output is correct
23 Correct 3 ms 23552 KB Output is correct
24 Correct 3 ms 23568 KB Output is correct
25 Correct 6 ms 23556 KB Output is correct
26 Correct 6 ms 23572 KB Output is correct
27 Correct 13 ms 23568 KB Output is correct
28 Correct 13 ms 23544 KB Output is correct
29 Correct 3 ms 23528 KB Output is correct
30 Correct 9 ms 23532 KB Output is correct
31 Correct 6 ms 23516 KB Output is correct
32 Correct 6 ms 23516 KB Output is correct
33 Correct 3 ms 23516 KB Output is correct
34 Correct 3 ms 23520 KB Output is correct
35 Correct 3 ms 23544 KB Output is correct
36 Correct 6 ms 23252 KB Output is correct
37 Correct 3 ms 23576 KB Output is correct
38 Correct 9 ms 24152 KB Output is correct
39 Correct 19 ms 24584 KB Output is correct
40 Correct 33 ms 25536 KB Output is correct
41 Correct 36 ms 26992 KB Output is correct
42 Correct 69 ms 27804 KB Output is correct
43 Correct 106 ms 28740 KB Output is correct
44 Correct 129 ms 31340 KB Output is correct
45 Correct 206 ms 32524 KB Output is correct
46 Correct 233 ms 33840 KB Output is correct
47 Correct 309 ms 38348 KB Output is correct
48 Correct 373 ms 39912 KB Output is correct
49 Correct 1199 ms 62652 KB Output is correct
50 Correct 1276 ms 63268 KB Output is correct
51 Execution timed out 1500 ms 97776 KB Execution timed out
52 Halted 0 ms 0 KB -