답안 #484162

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
484162 2021-11-02T08:49:01 Z ToroTN Bitaro the Brave (JOI19_ho_t1) C++14
0 / 100
0 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
long long n,m,c[3005][3005][2],r[3005][3005][2],cnt=0;
char s[3005][3005];
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s[i]+1);
    }
    /*for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i][j]=='O')
            {
                c[i][j][0]=c[i-1][j][0]+1;
                r[i][j][0]=r[i][j-1][0]+1;
            }else
            {
                c[i][j][0]=c[i-1][j][0];
                r[i][j][0]=r[i][j-1][0];
            }
            if(s[i][j]=='I')
            {
                c[i][j][1]=c[i-1][j][1]+1;
                r[i][j][1]=r[i][j-1][1]+1;
            }else
            {
                c[i][j][1]=c[i-1][j][1];
                r[i][j][1]=r[i][j-1][1];
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i][j]=='J')
            {
                cnt+=(c[n][j][0]-c[i][j][0])*(r[i][m][1]-r[i][j][1]);
                cnt+=(c[n][j][1]-c[i][j][1])*(r[i][m][0]-r[i][j][0]);
            }
        }
    }
    printf("%lld\n",cnt);*/
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=i+1;k<=n;k++)
            {
                for(int l=j+1;l<=n;l++)
                {
                    if(s[i][j]=='J'&&s[i][l]=='O'&&s[k][j]=='I'||s[i][j]=='J'&&s[i][l]=='I'&&s[k][j]=='O')
                    {
                        ++cnt;
                    }
                }
            }
        }
    }
    printf("%lld\n",cnt);
}

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:56:50: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   56 |                     if(s[i][j]=='J'&&s[i][l]=='O'&&s[k][j]=='I'||s[i][j]=='J'&&s[i][l]=='I'&&s[k][j]=='O')
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
joi2019_ho_t1.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%s",s[i]+1);
      |         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -