답안 #4861

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4861 2014-01-05T17:01:28 Z tncks0121 돌 무게 재기 (IZhO11_stones) C++
52 / 100
84 ms 5180 KB
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <memory.h> 
#include <math.h> 
#include <assert.h> 
#include <stack> 
#include <queue> 
#include <map> 
#include <set> 
#include <algorithm> 
#include <string> 
#include <functional> 
#include <vector> 
#include <deque> 
#include <utility> 
#include <bitset> 
#include <limits.h>  
#include <time.h>

using namespace std; 
typedef long long ll; 
typedef unsigned long long llu; 
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;

const int LEAF = 131072;
const int N_ = 100005;

int N;

struct node {
	int sum, tag;
	int mn, mx;
} Tree[LEAF+LEAF];

void spread (int nd, int len) {
	if(nd < LEAF) {
		for(int k = 0; k < 2; k++) {
			Tree[nd+nd+k].sum += Tree[nd].tag * (len/2);
			Tree[nd+nd+k].mn += Tree[nd].tag;
			Tree[nd+nd+k].mx += Tree[nd].tag;
			Tree[nd+nd+k].tag += Tree[nd].tag;
		}
		Tree[nd].tag = 0;
	}
}

void update (int nd, int nl, int nr, int x, int y, int d) {
	node &u = Tree[nd];
	int nmid = (nl + nr) >> 1;

	spread(nd, nr-nl+1);

	if(x <= nl && nr <= y) {
		u.sum += d * (nr-nl+1);
		u.mn += d;
		u.mx += d;
		u.tag += d;
		return;
	}

	if(x <= nmid) 
		update(nd+nd, nl, nmid, x, min(y, nmid), d);
	if(y > nmid)
		update(nd+nd+1, nmid+1, nr, max(x, nmid+1), y, d);
	
	Tree[nd].sum = Tree[nd+nd].sum + Tree[nd+nd+1].sum;
	Tree[nd].mn = min(Tree[nd+nd].mn, Tree[nd+nd+1].mn);
	Tree[nd].mx = max(Tree[nd+nd].mx, Tree[nd+nd+1].mx);
	Tree[nd].tag = 0;
}

void update (int p, int d) {
	update(1, 1, LEAF, 1, p, d);
}

int main() {
	int i, j, k;
	
	scanf("%d", &N);
	while(N--) {
		int r, s; scanf("%d%d", &r, &s);
		int v = (s == 1) ? 1 : -1;
		update(r, v);
		bool h1 = (Tree[1].mn >= 0);
		bool h2 = (Tree[2].mx <= 0);
		putchar((h1 ^ h2) ? (h1 ? '>' : '<') : '?');
		putchar('\n');
//		printf("%d %d\n", Tree[1].mn, Tree[1].mx);
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5180 KB Output is correct - 73 tokens
2 Correct 0 ms 5180 KB Output is correct - 89 tokens
3 Correct 0 ms 5180 KB Output is correct - 221 tokens
4 Correct 0 ms 5180 KB Output is correct - 21 tokens
5 Correct 0 ms 5180 KB Output is correct - 369 tokens
6 Correct 0 ms 5180 KB Output is correct - 492 tokens
7 Correct 0 ms 5180 KB Output is correct - 945 tokens
8 Correct 0 ms 5180 KB Output is correct - 1237 tokens
9 Correct 0 ms 5180 KB Output is correct - 1105 tokens
10 Correct 7 ms 5180 KB Output is correct - 8921 tokens
11 Correct 50 ms 5180 KB Output is correct - 56110 tokens
12 Incorrect 73 ms 5180 KB Output isn't correct - 30218th words differ - expected: '?', found: '<'
13 Correct 76 ms 5180 KB Output is correct - 100000 tokens
14 Correct 72 ms 5180 KB Output is correct - 100000 tokens
15 Incorrect 75 ms 5180 KB Output isn't correct - 65539th words differ - expected: '?', found: '<'
16 Incorrect 71 ms 5180 KB Output isn't correct - 65527th words differ - expected: '?', found: '<'
17 Incorrect 84 ms 5180 KB Output isn't correct - 2nd words differ - expected: '>', found: '?'
18 Incorrect 77 ms 5180 KB Output isn't correct - 4th words differ - expected: '?', found: '<'
19 Incorrect 79 ms 5180 KB Output isn't correct - 21st words differ - expected: '?', found: '<'
20 Incorrect 77 ms 5180 KB Output isn't correct - 8th words differ - expected: '?', found: '<'
21 Incorrect 83 ms 5180 KB Output isn't correct - 8th words differ - expected: '>', found: '?'
22 Incorrect 79 ms 5180 KB Output isn't correct - 2nd words differ - expected: '>', found: '?'
23 Incorrect 74 ms 5180 KB Output isn't correct - 2nd words differ - expected: '>', found: '?'
24 Incorrect 78 ms 5180 KB Output isn't correct - 3rd words differ - expected: '?', found: '<'
25 Incorrect 75 ms 5180 KB Output isn't correct - 4th words differ - expected: '>', found: '?'