답안 #1099938

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099938 2024-10-12T07:11:17 Z Nurislam Examination (JOI19_examination) C++17
0 / 100
127 ms 15196 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>  
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long
#define ordst tree<int,  null_type,  less_equal<int>,  rb_tree_tag ,  tree_order_statistics_node_update >
template <class F, class _S>
bool chmin(F &u, const _S &v){
	bool flag = false;
	if ( u > v ){
		u = v; flag |= true;
	}
	return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
	bool flag = false;
	if ( u < v ){
		u = v; flag |= true;
	}
	return flag;
}

//const int N = (1<<18) +1, inf = LLONG_MAX;
//int mod = 998244353;
//int mod = 1000000007;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng)

void solve(){
	int n, q;
	cin >> n >> q;
	vector<array<int,2>> v(n);
	for(auto &[i, j]:v)cin >> i >> j;
	sort(rall(v));
	vector<array<int,4>> qu(q);
	int it = 0;
	for(auto &[i, j, k, l]:qu)cin >> i >> j >> k, l = it++;
	sort(rall(qu));
	ordst st;
	vector<int> ans(q, 0);
	it = 0;
	for(int i = 0; i < q; i++){
		auto &[a, b, c, id] = qu[i];
		while(it < n && v[it][0] >= a){
			st.insert(v[it][1]);
			it++;
		}
		if(st.empty())continue;
		int l = st.order_of_key(b);
		if(*st.find_by_order(l) >= b)l--;
		ans[id] = st.size() - l-1;
	}
	for(int i:ans)cout << i << '\n';
	
	
}
signed main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 127 ms 15196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 127 ms 15196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 352 KB Output isn't correct
2 Halted 0 ms 0 KB -