Submission #594157

# Submission time Handle Problem Language Result Execution time Memory
594157 2022-07-12T07:18:32 Z Cross_Ratio Sandcastle 2 (JOI22_ho_t5) C++14
9 / 100
7 ms 596 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> P;
const int INF = 1e18;
vector<vector<int>> A;
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N, M;
    cin >> N>> M;
    A.resize(N);
    int i, j;
    for(i=0;i<N;i++) {
        A[i].resize(M);
        for(j=0;j<M;j++) cin >> A[i][j];
    }
    int ans = N*M;
    for(i=0;i<N;i++) {
        int pt = 0;
        while(pt+1<M) {
            if(A[i][pt]<A[i][pt+1]) {
                int cnt = 1;
                while(pt+1<M&&A[i][pt]<A[i][pt+1]) {
                    pt++;
                    cnt++;
                }
                ans += cnt * (cnt - 1) / 2;
            }
            else {
                int cnt = 1;
                while(pt+1<M&&A[i][pt]>A[i][pt+1]) {
                    pt++;
                    cnt++;
                }
                ans += cnt * (cnt - 1) / 2;
            }
            //cout << pt << ' ' << ans << '\n';
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 7 ms 596 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
4 Correct 6 ms 596 KB Output is correct
5 Correct 7 ms 596 KB Output is correct
6 Correct 6 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -