Submission #167587

# Submission time Handle Problem Language Result Execution time Memory
167587 2019-12-09T04:07:48 Z abil Weighting stones (IZhO11_stones) C++14
100 / 100
65 ms 4572 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long

using namespace std;

const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);

int mx[N], mn[N], sum[N];

void push(int v,int l,int r){
	if(l != r){
		sum[v + v] += sum[v];
		sum[v + v + 1] += sum[v];
	}
	mx[v] += sum[v];
	mn[v] += sum[v];
	sum[v] = 0;
}

void upd(int v, int tl, int tr,int l,int r, int val){
	push(v, tl, tr);
	if(tl > r || tr < l){
		return;
	}
	if(l <= tl && tr <= r){
		sum[v] += val;
		push(v, tl, tr);
		return;
	}
	int mid = (tl + tr) >> 1;
	upd(v + v, tl, mid, l, r, val);
	upd(v + v + 1, mid + 1, tr, l, r, val);
	mx[v] = max(mx[v + v], mx[v + v + 1]);
	mn[v] = min(mn[v + v], mn[v + v + 1]);
}

main()
{
	int n, ves, side, ans;
	scanf("%d", &n);
	int test = n;
	while(test--){
		scanf("%d%d", &ves, &side);
		if(side == 1){
			upd(1, 1, n, 1, ves, 1);
		}
		else{
			upd(1, 1, n, 1, ves, -1);
		}
		if(mx[1] >= 0 && mn[1] >= 0){
			puts(">");
		}
		else
		if(mx[1] <= 0 && mn[1] <= 0){
			puts("<");
		}
		else{
			puts("?");
		}
	}
}

Compilation message

stones.cpp:45:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
stones.cpp: In function 'int main()':
stones.cpp:47:20: warning: unused variable 'ans' [-Wunused-variable]
  int n, ves, side, ans;
                    ^~~
stones.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
stones.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &ves, &side);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 7 ms 760 KB Output is correct
11 Correct 39 ms 2424 KB Output is correct
12 Correct 65 ms 4344 KB Output is correct
13 Correct 64 ms 4472 KB Output is correct
14 Correct 64 ms 4472 KB Output is correct
15 Correct 64 ms 4456 KB Output is correct
16 Correct 65 ms 4572 KB Output is correct
17 Correct 63 ms 4436 KB Output is correct
18 Correct 64 ms 4444 KB Output is correct
19 Correct 64 ms 4388 KB Output is correct
20 Correct 63 ms 4436 KB Output is correct
21 Correct 63 ms 4344 KB Output is correct
22 Correct 64 ms 4344 KB Output is correct
23 Correct 64 ms 4356 KB Output is correct
24 Correct 64 ms 4344 KB Output is correct
25 Correct 64 ms 4344 KB Output is correct