답안 #954954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954954 2024-03-29T00:53:31 Z ByeWorld Examination (JOI19_examination) C++14
100 / 100
263 ms 24936 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define md ((l+r)>>1)
#define lf (id<<1)
#define rg ((id<<1)|1)
using namespace std;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> ipii;
const int MAXN = 3e5+10;
const ll INF = 2e18+10;
const ll LOG = 61;
const int MOD = 998244353;
 
struct fen {
	int st[2*MAXN];
    int que(int x){
        int te = 0;
        for(; x>=1; x-=(x&(-x))) te += st[x];
        return te;
    }
    void upd(int x, int p){
        for(; x<=2*MAXN-10; x+=(x&(-x))) st[x] += p;
    }
} A, B;
 
int n, q;
vector <pii> vec;
vector <pair<pii,pii>> que;
vector <int> cc1, cc2;
int x[MAXN], y[MAXN], z[MAXN], X[MAXN], Y[MAXN];
int ans[MAXN];
 
signed main() {
	cin >> n >> q;
	for(int i=1; i<=n; i++){
		cin >> X[i] >> Y[i];
		cc1.pb(X[i]); cc2.pb(Y[i]); 
		vec.pb({X[i]+Y[i], i});
	}
 
	for(int i=1; i<=q; i++){
		int a, b, c; cin >> a >> b >> c;
        c = max(c, a+b);
		que.pb({{c, i}, {a, b}});
		cc1.pb(a); cc2.pb(b);
	}
	sort(que.rbegin(), que.rend());
 
	cc1.pb(-1);
	sort(cc1.begin(), cc1.end());
	cc1.resize( unique(cc1.begin(), cc1.end()) - cc1.begin() );
	cc2.pb(-1);
	sort(cc2.begin(), cc2.end());
	cc2.resize( unique(cc2.begin(), cc2.end()) - cc2.begin() );
 
	for(int i=1; i<=n; i++){
		x[i] = lower_bound(cc1.begin(), cc1.end(), X[i]) - cc1.begin();
		y[i] = lower_bound(cc2.begin(), cc2.end(), Y[i]) - cc2.begin();
		// cout << i << ' ' << y[i] << ' ' << z[i] << " ins\n";
	}
	vec.pb({INF, INF}); // sort based on x[i]+y[i]
	sort(vec.rbegin(), vec.rend());
 
	int las = 1;
	for(int i=0; i<q; i++){
		int c = que[i].fi.fi, id = que[i].fi.se;
		int a = lower_bound(cc1.begin(), cc1.end(), que[i].se.fi) - cc1.begin();
		int b = lower_bound(cc2.begin(), cc2.end(), que[i].se.se) - cc2.begin();
		// cout << id << ' '<< b << ' ' << c << " que\n";
		while(las<=n && c <= vec[las].fi){
			int idx = vec[las].se;
			// cout << y[idx] << ' '<< z[idx] << " idxupd\n";
			A.upd(x[idx], 1);
            B.upd(y[idx], 1);
			las++;
		}
        int neg = A.que(a-1) + B.que(b-1); // negate yg di X, Y
		ans[id] = las-1 - neg; 
	}
 
	for(int i=1; i<=q; i++) cout << ans[i] << "\n"; //[i==q];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8536 KB Output is correct
2 Correct 2 ms 8540 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 2 ms 8540 KB Output is correct
7 Correct 8 ms 9052 KB Output is correct
8 Correct 10 ms 9164 KB Output is correct
9 Correct 9 ms 9120 KB Output is correct
10 Correct 9 ms 9048 KB Output is correct
11 Correct 6 ms 9092 KB Output is correct
12 Correct 5 ms 10844 KB Output is correct
13 Correct 7 ms 9052 KB Output is correct
14 Correct 8 ms 11100 KB Output is correct
15 Correct 7 ms 11100 KB Output is correct
16 Correct 6 ms 9136 KB Output is correct
17 Correct 7 ms 9052 KB Output is correct
18 Correct 4 ms 9052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 19896 KB Output is correct
2 Correct 196 ms 22476 KB Output is correct
3 Correct 210 ms 21676 KB Output is correct
4 Correct 146 ms 22204 KB Output is correct
5 Correct 145 ms 21948 KB Output is correct
6 Correct 106 ms 20912 KB Output is correct
7 Correct 186 ms 22460 KB Output is correct
8 Correct 188 ms 22472 KB Output is correct
9 Correct 200 ms 22976 KB Output is correct
10 Correct 139 ms 20152 KB Output is correct
11 Correct 140 ms 21968 KB Output is correct
12 Correct 92 ms 19132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 19896 KB Output is correct
2 Correct 196 ms 22476 KB Output is correct
3 Correct 210 ms 21676 KB Output is correct
4 Correct 146 ms 22204 KB Output is correct
5 Correct 145 ms 21948 KB Output is correct
6 Correct 106 ms 20912 KB Output is correct
7 Correct 186 ms 22460 KB Output is correct
8 Correct 188 ms 22472 KB Output is correct
9 Correct 200 ms 22976 KB Output is correct
10 Correct 139 ms 20152 KB Output is correct
11 Correct 140 ms 21968 KB Output is correct
12 Correct 92 ms 19132 KB Output is correct
13 Correct 209 ms 21488 KB Output is correct
14 Correct 226 ms 23060 KB Output is correct
15 Correct 200 ms 21716 KB Output is correct
16 Correct 158 ms 22712 KB Output is correct
17 Correct 157 ms 20640 KB Output is correct
18 Correct 106 ms 20964 KB Output is correct
19 Correct 213 ms 21368 KB Output is correct
20 Correct 205 ms 23740 KB Output is correct
21 Correct 205 ms 21432 KB Output is correct
22 Correct 139 ms 21688 KB Output is correct
23 Correct 140 ms 20928 KB Output is correct
24 Correct 89 ms 19388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8536 KB Output is correct
2 Correct 2 ms 8540 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 2 ms 8540 KB Output is correct
7 Correct 8 ms 9052 KB Output is correct
8 Correct 10 ms 9164 KB Output is correct
9 Correct 9 ms 9120 KB Output is correct
10 Correct 9 ms 9048 KB Output is correct
11 Correct 6 ms 9092 KB Output is correct
12 Correct 5 ms 10844 KB Output is correct
13 Correct 7 ms 9052 KB Output is correct
14 Correct 8 ms 11100 KB Output is correct
15 Correct 7 ms 11100 KB Output is correct
16 Correct 6 ms 9136 KB Output is correct
17 Correct 7 ms 9052 KB Output is correct
18 Correct 4 ms 9052 KB Output is correct
19 Correct 198 ms 19896 KB Output is correct
20 Correct 196 ms 22476 KB Output is correct
21 Correct 210 ms 21676 KB Output is correct
22 Correct 146 ms 22204 KB Output is correct
23 Correct 145 ms 21948 KB Output is correct
24 Correct 106 ms 20912 KB Output is correct
25 Correct 186 ms 22460 KB Output is correct
26 Correct 188 ms 22472 KB Output is correct
27 Correct 200 ms 22976 KB Output is correct
28 Correct 139 ms 20152 KB Output is correct
29 Correct 140 ms 21968 KB Output is correct
30 Correct 92 ms 19132 KB Output is correct
31 Correct 209 ms 21488 KB Output is correct
32 Correct 226 ms 23060 KB Output is correct
33 Correct 200 ms 21716 KB Output is correct
34 Correct 158 ms 22712 KB Output is correct
35 Correct 157 ms 20640 KB Output is correct
36 Correct 106 ms 20964 KB Output is correct
37 Correct 213 ms 21368 KB Output is correct
38 Correct 205 ms 23740 KB Output is correct
39 Correct 205 ms 21432 KB Output is correct
40 Correct 139 ms 21688 KB Output is correct
41 Correct 140 ms 20928 KB Output is correct
42 Correct 89 ms 19388 KB Output is correct
43 Correct 262 ms 23944 KB Output is correct
44 Correct 258 ms 24252 KB Output is correct
45 Correct 260 ms 24936 KB Output is correct
46 Correct 184 ms 23208 KB Output is correct
47 Correct 183 ms 23204 KB Output is correct
48 Correct 116 ms 18852 KB Output is correct
49 Correct 257 ms 24760 KB Output is correct
50 Correct 263 ms 23636 KB Output is correct
51 Correct 244 ms 24764 KB Output is correct
52 Correct 198 ms 23224 KB Output is correct
53 Correct 171 ms 22460 KB Output is correct