이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define x first
#define y second
#define int long long
#define nl "\n"
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair <ll, ll> pii;
const int N = (int)1e6 + 7;
const int M = (int)5e6 + 7;
const ll MOD = (ll)1e9 + 7;
const int inf = (int)1e9 + 7;
const ll INF = (ll)3e18 + 7;
pii dir[] = {{-1, -1}, {1, 1}, {-1, 1}, {1, -1}};
int n, q, y[N];
void solve() {
cin >> n >> q;
for(int i = 1; i <= n; ++i) {
cin >> y[i];
}
while(q--) {
char tp;
cin >> tp;
int c, d;
if(tp == '1') {
cin >> c >> d;
y[c] = d;
} else {
cin >> d;
int ans = 0;
for(int i = 1; i < n; ++i) {
if(d >= y[i] && d <= y[i+1] || d >= y[i+1] && d <= y[i]) ans++;
}
cout << ans << nl;
}
}
}
signed main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
int test = 1;
//cin >> test;
for(int i = 1; i <= test; ++i) {
//cout << "Case " << i << ": ";
solve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
game.cpp: In function 'void solve()':
game.cpp:45:18: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
45 | if(d >= y[i] && d <= y[i+1] || d >= y[i+1] && d <= y[i]) ans++;
| ~~~~~~~~~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |