답안 #262685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
262685 2020-08-13T07:00:08 Z arnold518 청소 (JOI20_sweeping) C++14
0 / 100
18000 ms 126756 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1.5e6;

struct Point
{
	int x, y, p;
};

struct Query
{
	int t, p, x, y;
};

int N, M, Q;
Point A[MAXN+10];
Query B[MAXN+10];
int pos[MAXN+10];

struct SEG
{
	vector<int> tree, lazy;

	SEG()
	{
		tree.resize(MAXN*4+10);
		lazy.resize(MAXN*4+10);
	}

	void busy(int node, int tl, int tr)
	{
		tree[node]=max(tree[node], lazy[node]);
		if(tl!=tr)
		{
			lazy[node*2]=max(lazy[node*2], lazy[node]);
			lazy[node*2+1]=max(lazy[node*2+1], lazy[node]);
		}
		lazy[node]=0;
	}

	void update(int node, int tl, int tr, int l, int r, int k)
	{
		if(l>r) return;
		busy(node, tl, tr);
		if(r<tl || tr<l) return;
		if(l<=tl && tr<=r)
		{
			lazy[node]=k;
			busy(node, tl, tr);
			return;
		}
		int mid=tl+tr>>1;
		update(node*2, tl, mid, l, r, k);
		update(node*2+1, mid+1, tr, l, r, k);
	}

	void update2(int node, int tl, int tr, int p, int k)
	{
		busy(node, tl, tr);
		if(tl==tr) { tree[node]=k; return; }
		int mid=tl+tr>>1;
		if(p<=mid) update2(node*2, tl, mid, p ,k);
		else update2(node*2+1, mid+1, tr, p, k);
	}

	int query(int node, int tl, int tr, int p)
	{
		busy(node, tl, tr);
		if(tl==tr) return tree[node];
		int mid=tl+tr>>1;
		if(p<=mid) return query(node*2, tl, mid, p);
		else return query(node*2+1, mid+1, tr, p);
	}
}segx, segy;

int main()
{
	scanf("%d%d%d", &N, &M, &Q);
	for(int i=1; i<=M; i++) scanf("%d%d", &A[i].x, &A[i].y), A[i].p=i;

	for(int i=1; i<=Q; i++)
	{
		scanf("%d", &B[i].t);
		if(B[i].t==1) scanf("%d", &B[i].p);
		else if(B[i].t==2) scanf("%d", &B[i].x);
		else if(B[i].t==3) scanf("%d", &B[i].x);
		else if(B[i].t==4)
		{
			scanf("%d%d", &B[i].x, &B[i].y);
			B[i].p=++M;
			A[M]={B[i].x, B[i].y, M};
		}
	}


	for(int i=1; i<=Q; i++)
	{
		if(B[i].t==1)
		{
			printf("%d %d\n", A[B[i].p].x, A[B[i].p].y);
		}
		else if(B[i].t==2)
		{
			for(int j=1; j<=M; j++)
			{
				if(A[j].x<=N-B[i].x && A[j].y<=B[i].x) A[j].x=N-B[i].x;
			}
		}
		else if(B[i].t==3)
		{
			for(int j=1; j<=M; j++)
			{
				if(A[j].x<=B[i].x && A[j].y<=N-B[i].x) A[j].y=N-B[i].x;
			}
		}
		else
		{
			A[B[i].p]={A[i].x, A[i].y};
		}
	}
}

Compilation message

sweeping.cpp: In member function 'void SEG::update(int, int, int, int, int, int)':
sweeping.cpp:57:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   57 |   int mid=tl+tr>>1;
      |           ~~^~~
sweeping.cpp: In member function 'void SEG::update2(int, int, int, int, int)':
sweeping.cpp:66:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   66 |   int mid=tl+tr>>1;
      |           ~~^~~
sweeping.cpp: In member function 'int SEG::query(int, int, int, int)':
sweeping.cpp:75:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   75 |   int mid=tl+tr>>1;
      |           ~~^~~
sweeping.cpp: In function 'int main()':
sweeping.cpp:83:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   83 |  scanf("%d%d%d", &N, &M, &Q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sweeping.cpp:84:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   84 |  for(int i=1; i<=M; i++) scanf("%d%d", &A[i].x, &A[i].y), A[i].p=i;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
sweeping.cpp:88:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   88 |   scanf("%d", &B[i].t);
      |   ~~~~~^~~~~~~~~~~~~~~
sweeping.cpp:89:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   89 |   if(B[i].t==1) scanf("%d", &B[i].p);
      |                 ~~~~~^~~~~~~~~~~~~~~
sweeping.cpp:90:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   90 |   else if(B[i].t==2) scanf("%d", &B[i].x);
      |                      ~~~~~^~~~~~~~~~~~~~~
sweeping.cpp:91:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   91 |   else if(B[i].t==3) scanf("%d", &B[i].x);
      |                      ~~~~~^~~~~~~~~~~~~~~
sweeping.cpp:94:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   94 |    scanf("%d%d", &B[i].x, &B[i].y);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 76 ms 94584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 18023 ms 126756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 18106 ms 116852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 18106 ms 116852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 76 ms 94584 KB Output isn't correct
2 Halted 0 ms 0 KB -