Submission #12913

# Submission time Handle Problem Language Result Execution time Memory
12913 2015-01-20T06:44:42 Z baneling100 탐사 (KOI13_probe) C++
14.63 / 19
2000 ms 668 KB
#include <stdio.h>

int K, N, Probe[41][1001][3], Len[41], Ans[41];

int backTrack(int now) {

    int i, OK;

    if(now>K)
        return 1;
    else {
        Ans[now]=Ans[now-1]+1;
        OK=1;
        for(i=1 ; i<=Len[now] && OK ; i++) {
            if(now==Probe[now][i][2]) {
                if(Ans[now]-Ans[Probe[now][i][0]]!=Probe[now][i][1])
                    OK=0;
            }
            else
                if(Ans[now]-Ans[Probe[now][i][0]]>Probe[now][i][1])
                    OK=0;
        }
        if(OK)
            if(backTrack(now+1))
                return 1;
        Ans[now]=Ans[now-1];
        OK=1;
        for(i=1 ; i<=Len[now] && OK ; i++) {
            if(now==Probe[now][i][2]) {
                if(Ans[now]-Ans[Probe[now][i][0]]!=Probe[now][i][1])
                    OK=0;
            }
            else
                if(Ans[now]-Ans[Probe[now][i][0]]>Probe[now][i][1])
                    OK=0;
        }
        if(OK)
            if(backTrack(now+1))
                return 1;
    }
    return 0;
}

int main(void) {

    int i, j, in1, in2, in3;

    scanf("%d %d",&K,&N);
    for(i=1 ; i<=N ; i++) {
        scanf("%d %d %d",&in1,&in2,&in3);
        for(j=in1 ; j<=in2 ; j++) {
            Len[j]++;
            Probe[j][Len[j]][0]=in1-1;
            Probe[j][Len[j]][1]=in3;
            Probe[j][Len[j]][2]=in2;
        }
    }
    if(backTrack(1))
        for(i=1 ; i<=K ; i++) {
            if(Ans[i]-Ans[i-1])
                printf("#");
            else
                printf("-");
        }
    else
        printf("NONE");

    return 0;
}

Compilation message

probe.cpp: In function 'int main()':
probe.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&K,&N);
     ~~~~~^~~~~~~~~~~~~~~
probe.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d",&in1,&in2,&in3);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 43 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 436 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 363 ms 668 KB Output is correct
2 Correct 841 ms 500 KB Output is correct
3 Execution timed out 2036 ms 604 KB Time limit exceeded
4 Halted 0 ms 0 KB -