Submission #505359

# Submission time Handle Problem Language Result Execution time Memory
505359 2022-01-11T04:39:45 Z mansur Simple game (IZhO17_game) C++17
0 / 100
6 ms 10444 KB
#include<bits/stdc++.h>	
 
#pragma optimize ("g",on)
#pragma GCC optimize ("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
#pragma comment(linker, "/stack:200000000")

//01001101 01100001 01101011 01101000 01100001  01100111 01100001 01111001 

using namespace std;

#define all(a) a.begin(), a.end()                                                   
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define pb push_back
#define sz(a) a.size()
#define nl '\n'
#define popb pop_back()                                                                   
#define ld double
#define ull unsigned long long
#define ff first                                         
#define ss second  
#define fix fixed << setprecision
#define pii pair<int, int>                          
#define E exit (0)
#define int long long
 
const int inf = 1e9, N = 1e6 + 1, mod = 998244353;                    

vector<pii> dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int t[4 * N];

void update(int u, int tl, int tr, int l, int r, int val) {
	if (tl > r || tr < l) return;
	if (tl >= l && tr <= r) {
		t[u] += val;
		return;
	}
	int mid = (tl + tr) / 2;
	update(u * 2, tl, mid, l, r, val);
	update(u * 2 + 1, mid + 1, tr, l, r, val);
}

int get(int u, int tl, int tr, int pos) {
	if (tl == tr) return t[u];
	int mid = (tl + tr) / 2;
	if (pos <= mid) return get(u * 2, tl, mid, pos) + t[u];
	return get(u * 2 + 1, mid + 1, tr, pos) + t[u];
}

main() {                                                         
	//freopen("cowrect.in", "r", stdin);                                                                                     
	//freopen("cowrect.out", "w", stdout);                                                                                     
	ios_base::sync_with_stdio(NULL);                                                                                        
	cin.tie(NULL);  
	int n, m;
	cin >> n >> m;
	int y[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> y[i];
		if (i > 1) {
			update(1, 1, N, min(y[i - 1], y[i]), max(y[i - 1], y[i]), 1);
		}
	}
	while (m--) {
		int tp;
		cin >> tp;
		if (tp == 1) {
			int i, val;
			cin >> i >> val;
			if (i > 1)
				update(1, 1, N - 1, min(y[i - 1], y[i]), max(y[i - 1], y[i]), -1);
			if (i < n) 
				update(1, 1, N - 1, min(y[i + 1], y[i]), max(y[i + 1], y[i]), -1);
			y[i] = val;
			if (i > 1)
				update(1, 1, N - 1, min(y[i - 1], y[i]), max(y[i - 1], y[i]), 1);
			if (i < n) 
				update(1, 1, N - 1, min(y[i + 1], y[i]), max(y[i + 1], y[i]), 1);
		}else {
			int h;
			cin >> h;
			cout << get(1, 1, N - 1, h) << nl;
		}
	}
}

Compilation message

game.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize ("g",on)
      | 
game.cpp:9: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    9 | #pragma comment(linker, "/stack:200000000")
      | 
game.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 6 ms 10444 KB Output is correct
3 Incorrect 6 ms 10188 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 6 ms 10444 KB Output is correct
3 Incorrect 6 ms 10188 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 6 ms 10444 KB Output is correct
3 Incorrect 6 ms 10188 KB Output isn't correct
4 Halted 0 ms 0 KB -