This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define tup tuple<int, int, int>
#define pii pair<int, int>
#define fi first
#define se second
#define pub push_back
#define pob pop_back
int n;
signed main() {
ioss;
cin >> n;
int x[n+2] = {}, y[n+2] = {};
if(n == 2) {
cin >> x[1] >> y[1] >> x[2] >> y[2];
if(abs(x[1]-x[2]) <= y[1]-y[2] || abs(x[1]-x[2]) <= y[2]-y[1]) cout << 1 << endl;
else cout << 2 << endl;
return 0;
}
bool one = 1, diff = 0;
for(int i = 1; i <= n; i++) {
cin >> x[i] >> y[i];
if(y[i] != 1) one = 0;
if(x[i] != i) diff = 1;
}
if(one) {
int ans = 1;
for(int i = 2; i <= n; i++) {
if(x[i] != x[i-1]) ans++;
}
cout << ans << endl;
return 0;
}
if(!diff) {
int ans = 0;
for(int i = 1; i <= n; i++) {
if(i == n) {
if(y[i-1] <= y[i]) ans++;
}
else {
if(y[i] > y[i+1]) ans++, i++;
else if(y[i] == y[i+1]) ans++;
}
}
cout << ans << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |