제출 #758056

#제출 시각아이디문제언어결과실행 시간메모리
758056vjudge1Simple game (IZhO17_game)C++17
22 / 100
1082 ms740 KiB
#include <bits/stdc++.h>
#include <array>
#define setall(a, val) for(auto& x : a) x = val
#define all(v) (v.begin()), (v.end())
#define cerr (cerr << "D: ")
#define ll long long
using namespace std;
clock_t start_time;
double get_time() { return (double)(clock() - start_time) / CLOCKS_PER_SEC; }
void init(bool oj = 0) {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	srand(time(0)); start_time = clock();
	if (!oj) {
#ifndef ONLINE_JUDGE
		FILE* _ = freopen("in.txt", "r", stdin);
		//FILE* __ = freopen("out.txt", "w", stdout);
#endif
	}
}
const ll HASH_BASE = 31;
const ll MOD = 2000000011;
const ll N = 1e6 + 7;
const ll M = 1e7 + 1e7 / 2;
//####################################################################################

int main() {
	init(1);

	int n, q;
	cin >> n >> q;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];

	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			int i, x;
			cin >> i >> x;
			v[--i] = x;
		}
		else {
			int x, a = 0;
			cin >> x;
			bool b = (v[0] > x);
			for (int i = 1; i < n; i++) {
				if (b) {
					if (v[i] < x)
						b = 0, a++;
				}
				else {
					if (v[i] > x)
						b = 1, a++;
				}
			}
			cout << a << endl;
		}
	}

	cerr << get_time() << "s" << endl;
}

컴파일 시 표준 에러 (stderr) 메시지

game.cpp: In function 'void init(bool)':
game.cpp:15:9: warning: unused variable '_' [-Wunused-variable]
   15 |   FILE* _ = freopen("in.txt", "r", stdin);
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...