제출 #22360

#제출 시각아이디문제언어결과실행 시간메모리
22360AcornCkiGs14004Team (#40)Donut-shaped Enclosure (KRIII5_DE)C++14
2 / 7
1500 ms97776 KiB
#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);
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...