답안 #204120

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
204120 2020-02-24T13:13:57 Z pxh612 Coin Collecting (JOI19_ho_t4) C++14
0 / 100
5 ms 376 KB
#include<bits/stdc++.h>
#define int ll
//{ PXH612
using namespace std;
#define ll long long
#define db double
#define pp pair<int,int>
#define x first
#define y second

#define false(x) if(!(x))
template<typename A,typename B>bool Min(A &a,B b){if(a<=b) return 0;a=b;return 1;}
template<typename A,typename B>bool Max(A &a,B b){if(a>=b) return 0;a=b;return 1;}
#define in ({ll x=0;int o=0,c=char(),t=0;for(;!isdigit(c)&&t<1000;c=getchar(),t++) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})

#define FOR(i,a,b) for(int i=a,ENDFOR=b;i<=ENDFOR;i++)
#define ROF(i,a,b) for(int i=b,ENDFOR=a;ENDFOR<=i;i--)
#define RR(x,a,b) {cout<<#x<<": ";FOR(_,a,b) cout<<x[_]<<" ";cout<<"\n";}
#define rr(x) " "<<#x<<'='<<(x)<<" "

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define vn(a) (int)a.size()-1

#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define mu(x) (1ll<<x)
#define bitnum(x) __builtin_popcountll(x)

#define segg(a,b) (abs(a-b)+1)
#define midd(a,b) (a+(b-(a))/2)
#define mems(x,a) memset(x,a,sizeof x)
#define open(a) freopen(a,"r",stdin)
#define shut(b) freopen(b,"w",stdout)
//}/////////////////////////////////////////////////////}

const int N=1e5+5;
int n;
ll res=0;
int f[N][5];
int d[N][5];

int sum[5];
main()
{
 //   open("coin.inp");
    n=in;
    FOR(i,1,n*2)
    {
        int x=in,y=in;
        int X=x,Y=y;
        Max(X,1);Min(X,n);
        Max(Y,1);Min(Y,2);
        res+=abs(x-X)+abs(y-Y);
        f[X][Y]++;
    }


    FOR(i,1,n)
    {
      //  cout<<"=================" rr(i) "\n";
        FOR(ud,1,2) res+=abs(sum[ud]);
        FOR(ud,1,2) sum[ud]+=f[i][ud]-1;
        if(sum[1]>0&&sum[2]<0)
        {
            sum[1]--;
            sum[2]++;
            res++;
        }
        if(sum[1]<0&&sum[2]>0)
        {
            sum[1]++;
            sum[2]--;
            res++;
        }
    }
    cout<<res;
}

Compilation message

joi2019_ho_t4.cpp:46:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Incorrect 5 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Incorrect 5 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Incorrect 5 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -