Submission #594195

# Submission time Handle Problem Language Result Execution time Memory
594195 2022-07-12T08:10:50 Z 박상훈(#8431) Sandcastle 2 (JOI22_ho_t5) C++17
9 / 100
5 ms 852 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
int n, m;
vector<vector<int>> a;

void solve1(){
    int pt = 0;
    ll ans = 0;
    bool flag;
    for (int i=1;i<=m;i++){
        if (i==m) {ans++; break;}
        if (pt<=i){
           pt = i+1;
           flag = (a[1][i] < a[1][pt]);
        }

        while(pt<m && flag==(a[1][pt] < a[1][pt+1])) pt++;
        ans += pt - i + 1;

        //printf("%d: %d\n", i, pt);
    }
    printf("%lld\n", ans);
    exit(0);
}

int main(){
    scanf("%d %d", &n, &m);
    a.resize(n+1, vector<int>(m+1, 0));
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            scanf("%d", &a[i][j]);
        }
    }

    if (n==1) solve1();
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:33:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |             scanf("%d", &a[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~
Main.cpp: In function 'void solve1()':
Main.cpp:19:20: warning: 'flag' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |         while(pt<m && flag==(a[1][pt] < a[1][pt+1])) pt++;
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 5 ms 852 KB Output is correct
4 Correct 5 ms 852 KB Output is correct
5 Correct 5 ms 852 KB Output is correct
6 Correct 5 ms 852 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 -