Submission #20216

#TimeUsernameProblemLanguageResultExecution timeMemory
20216forever426탐사 (KOI13_probe)C11
14.63 / 19
2081 ms376 KiB
#include <stdio.h> #include <stdlib.h> #include <string.h> int K, N; typedef struct st { int s; int e; int n; }SEARCH; SEARCH S[1000+10]; int Map[40+5]; int End[40+5]; int Check_sum[41][41]; int Check_line[41][2]; int CMP(const void * a, const void * b) { return ((SEARCH*)a)->e - ((SEARCH*)b)->e; } int DFS(int n, int c) { int i, m; if(n>K) return 1; Map[n] = c; for(i=n; i>0; i--) Check_sum[i][n] = Check_sum[i][n-1] + c; if(Check_line[n][0]<Check_sum[Check_line[n][1]][n]) return 0; m = End[n]; while(n==S[m].e) { if(Check_sum[S[m].s][n] != S[m].n) return 0; m--; } if(DFS(n+1, 1)) return 1; if(DFS(n+1, 0)) return 1; return 0; } int main(void) { int i, j; scanf("%d%d", &K, &N); for(i=1; i<=N; i++) scanf("%d%d%d", &S[i].s, &S[i].e, &S[i].n); qsort(S+1, N, sizeof(S[0]), CMP); for(j=0; j<=K; j++) Check_line[j][0] = 50; for(i=1; i<=N; i++) { for(j=S[i].s; j<=S[i].e; j++) { if(Check_line[j][0] > S[i].n) { Check_line[j][0] = S[i].n; Check_line[j][1] = S[i].s; } } } for(i=1; i<=N; i++) End[S[i].e] = i; if(DFS(1,1) || DFS(1,0)) { for(i=1; i<=K; i++) { if(Map[i]) printf("#"); else printf("-"); } } else printf("NONE\n"); }

Compilation message (stderr)

probe.c: In function 'main':
probe.c:50:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &K, &N);
  ^~~~~~~~~~~~~~~~~~~~~
probe.c:52:22: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N; i++) scanf("%d%d%d", &S[i].s, &S[i].e, &S[i].n);
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...