Submission #375163

# Submission time Handle Problem Language Result Execution time Memory
375163 2021-03-09T03:53:26 Z daniel920712 Naan (JOI19_naan) C++14
5 / 100
1 ms 364 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

long long all[2005][2005];
long long sum[2005][2005]={0};
int main()
{
    long long N,M,a,b,x1,x2,y1,y2,c,i,j,ok=1;
    scanf("%lld %lld",&N,&M);
    for(i=0;i<N;i++)
    {
        sum[i][0]=0;
        for(j=1;j<=M;j++)
        {
            scanf("%lld",&all[i][j]);
            sum[i][j]=sum[i][j-1]+all[i][j];
        }
    }


    for(i=1;i<=M;i++)
    {
        ok=1;
        a=sum[1][i-1];
        b=all[1][i];
        c=sum[1][M];
        a*=2;
        b*=2;
        if(c-a>=0)
        {
            x1=c-a;
            y1=b;
        }
        else ok=0;

        a=sum[0][M]-sum[0][i];
        b=all[0][i];
        c=sum[0][M];
        a*=2;
        b*=2;

        if(a+b-c>=0)
        {
            x2=a+b-c;
            y2=b;
        }
        else ok=0;

        if(x1*y2<=x2*y1&&ok&&x1<=y1)
        {
            //printf("%lld\n",i);
            printf("%lld %lld\n",(i-1)*y1+x1,y1);
            printf("2 1\n");
            return 0;
        }

        ok=1;
        a=sum[0][i-1];
        b=all[0][i];
        c=sum[0][M];
        a*=2;
        b*=2;
        if(c-a>=0)
        {
            x1=c-a;
            y1=b;
        }
        else ok=0;


        a=sum[1][M]-sum[1][i];
        b=all[1][i];
        c=sum[1][M];
        a*=2;
        b*=2;

        if(a+b-c>=0)
        {
            x2=a+b-c;
            y2=b;
        }
        else ok=0;

        if(x1*y2<=x2*y1&&ok&&x1<=y1)
        {
            printf("%lld %lld\n",(i-1)*y1+x1,y1);
            printf("1 2\n");
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

Compilation message

naan.cpp: In function 'int main()':
naan.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     scanf("%lld %lld",&N,&M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
naan.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |             scanf("%lld",&all[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~
naan.cpp:56:19: warning: 'x1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |             printf("%lld %lld\n",(i-1)*y1+x1,y1);
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB X_i is not increasing
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Incorrect 1 ms 364 KB X_i is not increasing
18 Halted 0 ms 0 KB -