Submission #12177012


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

#define N 30
int a[N+2][N+2];
int disX[4] = {1,0,-1,0};
int disY[4] = {0,1,0,-1};
int sum = 0;

inline void input(){
    Rep(i,N) Rep(j,N) {
        Scd(a[i+1][j+1]);
        // a[i+1][j+1] = (i*419+j*312)%100;
        sum+=a[i+1][j+1];
    }
}

double neighbors( int bx, int by, int depth = 16 ){
    if( depth==0 ) return 0;
    if( a[bx][by] < 2 ) return 0;
    double ret = 0;
    Rep(i,4){
        int bbx = bx-disX[i];
        int bby = by-disY[i];
        if( a[bbx][bby]+1 == a[bx][by] )
            ret += 5*neighbors(bbx,bby,depth-1) + 101;
    }
    return ret;
}

double eval( int bx, int by, int px, int py ){
    if( a[px][py] == 0 ) return -1e12;
    double ret = a[px][py];
    if( abs(bx-px) + abs(by-py) == 1 && a[px][py] == a[bx][by] ) ret += 1e11;
    ret += neighbors(px,py);
    return ret;
}

void run( int x, int y ){
    printf ("%d %d\n", x, y );
    a[x][y]--;
    // Rep(i,N) Rep(j,N){
    //     printf ("%d%s", a[i+1][j+1], j == N-1 ? "\n" : "," );
    // }
    // printf ("\n");
    // int k;
    // Scd(k);
}

void solve(){
    int bestX = 0;
    int bestY = 0;
    int way = 0;

    while(sum--){
        int nextX = -1;
        int nextY = -1;
        double bestScore = -1e12;
        Repe(preX,N+1,1) Repe(preY,N+1,1){
            double preScore = eval(bestX,bestY,preX,preY);
            // printf ("%lld,%lld = %dpts\n", preX, preY, preScore );
            if( bestScore < preScore ){
                bestScore = preScore;
                nextX = preX;
                nextY = preY;
            }
        }
        if( abs(nextX-bestX) + abs(nextY-bestY) != 1 || 
            a[nextX][nextY] != a[bestX][bestY] ) way++;
        // printf ("---#%d.---\n", way );
        run(nextX,nextY);
        bestX = nextX;
        bestY = nextY;
    }

    // printf ("%d\n", way );

}

int main() {

    input();
    solve();

    return 0;
}

Submission Info

Submission Time
Task A - 高橋君の山崩しゲーム
User nishionyama
Language C++14 (GCC 5.4.1)
Score 813150
Code Size 3132 Byte
Status
Exec Time 411 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘void input()’:
./Main.cpp:55:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         Scd(a[i+1][j+1]);
                         ^

Judge Result

Set Name Score / Max Score Test Cases
test_01 81288 / 100000 subtask_01_01.txt
test_02 81440 / 100000 subtask_01_02.txt
test_03 81426 / 100000 subtask_01_03.txt
test_04 80789 / 100000 subtask_01_04.txt
test_05 81349 / 100000 subtask_01_05.txt
test_06 81035 / 100000 subtask_01_06.txt
test_07 81511 / 100000 subtask_01_07.txt
test_08 81578 / 100000 subtask_01_08.txt
test_09 81193 / 100000 subtask_01_09.txt
test_10 81541 / 100000 subtask_01_10.txt
Case Name Status Exec Time Memory
subtask_01_01.txt 381 ms 512 KB
subtask_01_02.txt 401 ms 512 KB
subtask_01_03.txt 381 ms 512 KB
subtask_01_04.txt 411 ms 512 KB
subtask_01_05.txt 386 ms 512 KB
subtask_01_06.txt 385 ms 512 KB
subtask_01_07.txt 396 ms 512 KB
subtask_01_08.txt 386 ms 512 KB
subtask_01_09.txt 393 ms 512 KB
subtask_01_10.txt 398 ms 512 KB