답안 #225221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225221 2020-04-19T15:43:34 Z Minnakhmetov 청소 (JOI20_sweeping) C++14
10 / 100
990 ms 72508 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

struct Q {
	int t, x, y;
};

const int N = 1e6 + 5;

vector<Q> qrs;
vector<pair<int, int>> pts;
vector<int> vy, app_time;
int t[N * 4];

void upd(int x, int y, int v, int L, int R) {
	t[v] = max(t[v], y);
	// cout << L << " " << R << "\n";
	if (L != R) {
		int m = (L + R) >> 1;
		if (x <= m)
			upd(x, y, v * 2, L, m);
		else
			upd(x, y, v * 2 + 1, m + 1, R);
	}
}

int que(int x, int y, int v, int L, int R) {
	// cout << x << " " << y << " " << L << " " << R << " " << t[v] << "\n";
	if (R < x || t[v] < y)
		return -1;
	if (t[v] < y)
		return -1;

	if (L == R)
		return L;
	int m = (L + R) >> 1,
		res = que(x, y, v * 2, L, m);
	if (res == -1)
		res = que(x, y, v * 2 + 1, m + 1, R);
	return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, q;
    cin >> n >> m >> q;

    for (int i = 0; i < m; i++) {
    	int x, y;
    	cin >> x >> y;
    	pts.push_back({x, y});
    	app_time.push_back(0);
    }

    for (int i = 0, j = 0; i < q; i++) {
    	int type, x;
    	cin >> type >> x;

    	if (type == 1) {
    		qrs.push_back({type, x - 1});
    	}
    	else if (type == 2) {
    		vy.push_back(x);
    		qrs.push_back({type, x, j});
    		j++;
    	}
    	else {
    		int y;
    		cin >> y;
    		pts.push_back({x, y});
    		app_time.push_back(j);
    	}
    }

    vy.push_back(-1);
    sort(all(vy));
    vy.erase(unique(all(vy)), vy.end());

    memset(t, -1, sizeof(t));

    int j = 0;
    for (const Q &q : qrs) {
    	if (q.t == 1) {
    		int res = que(lower_bound(all(vy), pts[q.x].second) - vy.begin(), app_time[q.x], 1, 0, vy.size() - 1);
    		if (res == -1)
    			cout << pts[q.x].first << " " << pts[q.x].second << "\n";
    		else
    			cout << max(pts[q.x].first, n - vy[res]) << " " << pts[q.x].second << "\n";
    	}
    	else if (q.t == 2) {
    		upd(lower_bound(all(vy), q.x) - vy.begin(), q.y, 1, 0, vy.size() - 1);
    	}
    }

    return 0;
}       

Compilation message

sweeping.cpp: In function 'int main()':
sweeping.cpp:86:9: warning: unused variable 'j' [-Wunused-variable]
     int j = 0;
         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 16256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 990 ms 59204 KB Output is correct
2 Correct 978 ms 68716 KB Output is correct
3 Correct 977 ms 68484 KB Output is correct
4 Correct 813 ms 67600 KB Output is correct
5 Correct 777 ms 68100 KB Output is correct
6 Correct 916 ms 72508 KB Output is correct
7 Correct 969 ms 68528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 836 ms 60872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 836 ms 60872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 16256 KB Output isn't correct
2 Halted 0 ms 0 KB -