제출 #1105154

#제출 시각아이디문제언어결과실행 시간메모리
1105154salmonBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
382 ms93528 KiB
#include <bits/stdc++.h>
using namespace std;

int H,W;
char lst[3100][3100];
int I[3100][3100];
int O[3100][3100];
long long int ans = 0;

int main(){

    scanf(" %d",&H);
    scanf(" %d",&W);

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            scanf(" %c",&lst[i][j]);
        }
    }

    for(int i = 0; i < H; i++){
        O[i][W - 1] = 0;
        if(lst[i][W - 1] == 'O'){
            O[i][W - 1]++;
        }

        for(int j = W - 2; j >= 0; j--){
            O[i][j] = O[i][j + 1];
            if(lst[i][j] == 'O') O[i][j]++;
        }
    }

    for(int j = 0; j < W; j++){
        I[H - 1][j] = 0;
        if(lst[H - 1][j] == 'I'){
            I[H - 1][j]++;
        }

        for(int i = H - 2; i >= 0; i--){
            I[i][j] = I[i + 1][j];
            if(lst[i][j] == 'I') I[i][j]++;
        }
    }

    for(int i = 0; i < H; i++){
        for(int j  = 0; j < W; j++){
            if(lst[i][j] == 'J') ans += I[i][j] * O[i][j];
        }
    }

    printf("%lld",ans);

}

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

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf(" %d",&H);
      |     ~~~~~^~~~~~~~~~
joi2019_ho_t1.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf(" %d",&W);
      |     ~~~~~^~~~~~~~~~
joi2019_ho_t1.cpp:17:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |             scanf(" %c",&lst[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...