답안 #153821

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
153821 2019-09-16T14:56:10 Z arnold518 Coin Collecting (JOI19_ho_t4) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N;
int A[3][MAXN+10];
ll ans;

int main()
{
    int i, j;

    scanf("%d", &N);
    for(i=1; i<=2*N; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        if(x<1) ans+=1-x, x=1;
        if(x>N) ans+=x-N, x=N;
        if(y<1) ans+=1-y, y=1;
        if(y>2) ans+=y-2, y=2;
        A[y][x]++;
    }

    for(j=1; j<=N; j++) printf("%d ", A[1][j]); printf("\n");
    for(j=1; j<=N; j++) printf("%d ", A[2][j]); printf("\n");
    printf("%lld\n", ans);
    for(i=1; i<N; i++)
    {
        if(A[1][i]<1 && A[2][i]>=1)
        {
            if(A[1][i]+A[2][i]>=2)
            {
                ans+=1-A[1][i];
                A[2][i]-=1-A[1][i];
                A[1][i]=1;
            }
            else
            {
                ans+=A[2][i]-1;
                A[1][i]+=A[2][i]-1;
                A[2][i]=1;
            }
        }
        if(A[2][i]<1 && A[1][i]>=1)
        {
            if(A[1][i]+A[2][i]>=2)
            {
                ans+=1-A[2][i];
                A[1][i]-=1-A[2][i];
                A[2][i]=1;
            }
            else
            {
                ans+=A[1][i]-1;
                A[2][i]+=A[1][i]-1;
                A[1][i]=1;
            }
        }

        if(A[1][i]>=1)
        {
            ans+=A[1][i]-1;
            A[1][i+1]+=A[1][i]-1; A[1][i]=1;
        }
        else
        {
            ans+=1-A[1][i];
            A[1][i+1]+=A[1][i]-1; A[1][i]=1;
        }

        if(A[2][i]>=1)
        {
            ans+=A[2][i]-1;
            A[2][i+1]+=A[2][i]-1; A[2][i]=1;
        }
        else
        {
            ans+=1-A[2][i];
            A[2][i+1]+=A[2][i]-1; A[2][i]=1;
        }
    }
    ans+=abs(A[1][N]-1);
    printf("%lld", ans);
}

Compilation message

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:30:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(j=1; j<=N; j++) printf("%d ", A[1][j]); printf("\n");
     ^~~
joi2019_ho_t4.cpp:30:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(j=1; j<=N; j++) printf("%d ", A[1][j]); printf("\n");
                                                 ^~~~~~
joi2019_ho_t4.cpp:31:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(j=1; j<=N; j++) printf("%d ", A[2][j]); printf("\n");
     ^~~
joi2019_ho_t4.cpp:31:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(j=1; j<=N; j++) printf("%d ", A[2][j]); printf("\n");
                                                 ^~~~~~
joi2019_ho_t4.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
joi2019_ho_t4.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -