답안 #27705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27705 2017-07-13T13:50:17 Z repeating 웜뱃 (IOI13_wombats) C++11
18 / 100
1986 ms 10716 KB
#include <bits/stdc++.h>
#include "wombats.h"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define WH while
#define RE return
#define CO continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%I64d",&x)
#define SF2(x,y) scanf("%I64d%I64d",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e9;
const int MX=100005;

int n,m;
int dis[5][5005][5];
int l[5005][5];
int r[5005][5];
int u[5005][5];
int d[5005][5];
bool bol;
priority_queue< pair<int,pii> , vector< pair<int,pii> > , greater< pair<int,pii> > > pq;
void dijkstra(int v1){
    pq.P({0,{0,v1}});
    WH(!pq.empty()){
        int D=pq.top().F,x=pq.top().S.F,y=pq.top().S.S;
        pq.pop();
        if(dis[v1][x][y]!=-1&&dis[v1][x][y]<=D)CO;
        dis[v1][x][y]=D;
        if(x!=n-1)
            pq.P({D+d[x][y],{x+1,y}});
        if(y!=m-1)
            pq.P({D+r[x][y],{x,y+1}});
        if(y!=0)
            pq.P({D+l[x][y],{x,y-1}});
    }
}
void init(int R_, int C_, int H[5000][200], int V[5000][200]) {
    n=R_,m=C_;
    for(int i=0;i<n;i++){
        for(int j=0;j<m-1;j++){
            r[i][j]=H[i][j];
            l[i][j+1]=H[i][j];
        }
    }
    for(int i=0;i<n-1;i++){
        for(int j=0;j<m;j++){
            d[i][j]=V[i][j];
            u[i+1][j]=V[i][j];
        }
    }
    MEM(dis,-1);
}
void changeH(int p, int q, int W) {
    r[p][q]=W;
    l[p][q+1]=W;
    MEM(dis,-1);
    for(int i=0;i<m;i++)
        dijkstra(i);
}

void changeV(int p, int q, int W) {
    d[p][q]=W;
    u[p+1][q]=W;
    MEM(dis,-1);
    for(int i=0;i<m;i++)
        dijkstra(i);
}
int escape(int V1, int V2) {
    return dis[V1][n-1][V2];
}
//#include <stdio.h>
//#include <stdlib.h>
//
//#define fail(s, x...) do { \
//		fprintf(stderr, s "\n", ## x); \
//		exit(1); \
//	} while(0)
//
//static int H[5000][200];
//static int V[5000][200];
//
//int main() {
//	int R, C, E, P, Q, W, V1, V2, event, i, j;
//	int res;
//
//	res = scanf( "%d%d", &R, &C);
//    for (i = 0; i < R; ++i)
//        for (j = 0; j < C-1; ++j)
//            res = scanf( "%d", &H[i][j]);
//    for (i = 0; i < R-1; ++i)
//        for (j = 0; j < C; ++j)
//            res = scanf( "%d", &V[i][j]);
//
//    init(R, C, H, V);
//
//	res = scanf( "%d", &E);
//	for (i = 0; i < E; i++) {
//		res = scanf( "%d", &event);
//        if (event == 1) {
//            res = scanf( "%d%d%d", &P, &Q, &W);
//            changeH(P, Q, W);
//        } else if (event == 2) {
//            res = scanf( "%d%d%d", &P, &Q, &W);
//            changeV(P, Q, W);
//        } else if (event == 3) {
//            res = scanf( "%d%d", &V1, &V2);
//            printf("%d\n", escape(V1, V2));
//        } else
//            fail("Invalid event type.");
//	}
//
//	return 0;
//}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^
wombats.cpp:86:1: warning: multi-line comment [-Wcomment]
 //#define fail(s, x...) do { \
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 10716 KB Output is correct
2 Correct 66 ms 10716 KB Output is correct
3 Correct 153 ms 10716 KB Output is correct
4 Correct 69 ms 10716 KB Output is correct
5 Correct 63 ms 10716 KB Output is correct
6 Incorrect 0 ms 10716 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 10716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 10716 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1053 ms 10716 KB Output is correct
2 Correct 1986 ms 10716 KB Output is correct
3 Correct 1076 ms 10716 KB Output is correct
4 Correct 1139 ms 10716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 10716 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 10716 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -