Submission #19860

# Submission time Handle Problem Language Result Execution time Memory
19860 2016-02-25T06:20:58 Z hjk0553 탐사 (KOI13_probe) C++
4.56 / 19
2000 ms 376 KB
#include<bits/stdc++.h>
int k,n,arr[44],sum[44];
struct d{
    int s;
    int e;
    int cnt;
} data[1111];
void f(int pos){
    int i,j,flag=1;
    if(pos>k){
        for(i=1;i<=k;i++) sum[i]=sum[i-1]+arr[i];
        for(i=1;i<=n;i++){
            int hap=sum[data[i].e]-sum[data[i].s-1];
            if(hap!=data[i].cnt) flag=0;
        }
        if(flag){
            for(i=1;i<=k;i++) printf("%c",arr[i]?'#':'-');
            exit(0);
        }
    }
    else{
        for(i=0;i<=1;i++){
            if(arr[pos]==-1){
                arr[pos]=i;
                f(pos+1);
                arr[pos]=-1;
            }
        }
    }
}
int main(){
    memset(arr,-1,sizeof(arr));
    int i;
    scanf("%d %d",&k,&n);
    for(i=1;i<=n;i++) scanf("%d %d %d",&data[i].s,&data[i].e,&data[i].cnt);
    f(1);
    printf("NONE");
    return 0;
}

Compilation message

probe.cpp: In function 'void f(int)':
probe.cpp:9:11: warning: unused variable 'j' [-Wunused-variable]
     int i,j,flag=1;
           ^
probe.cpp: In function 'int main()':
probe.cpp:34: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:35:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++) scanf("%d %d %d",&data[i].s,&data[i].e,&data[i].cnt);
                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 356 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 510 ms 364 KB Output is correct
4 Correct 103 ms 256 KB Output is correct
5 Correct 76 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2036 ms 252 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2081 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2057 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2005 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -