제출 #635385

#제출 시각아이디문제언어결과실행 시간메모리
635385NothingXDZIGZAG (INOI20_zigzag)C++17
8 / 100
2088 ms6856 KiB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << H;
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
#define F first
#define S second

const int maxn = 3e5 + 10;

int n, q, dp[maxn];
ll a[maxn];
vector<ll> num;

ll solve(){
	ll ans = 1;
	dp[0] = 1;
	for (int i = 1; i < num.size(); i++){
		dp[i] = 1;
		if (num[i] != num[i-1]) dp[i] = 2;
		if (i > 1 && ((num[i] > num[i-1] && num[i-2] > num[i-1]) || (num[i] < num[i-1] && num[i-2] < num[i-1]))) dp[i] = dp[i-1] + 1;
		ans += dp[i];
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);

	cin >> n >> q;

	for (int i = 1; i <= n; i++) cin >> a[i];


	while(q--){
		char t; int l, r; cin >> t >> l >> r;
		if (t == '*'){
			for (int i = l; i <= r; i++) a[i] = -a[i];
		}
		if (t == '+'){
			int x; cin >> x;
			for (int i = l; i <= r; i++) a[i] += x;
		}
		if (t == '?'){
			num.clear();
			for (int i = l; i <= r; i++) num.push_back(a[i]);
			cout << solve() << '\n';
		}
	}

	return 0;
}

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

Main.cpp: In function 'll solve()':
Main.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for (int i = 1; i < num.size(); i++){
      |                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...