# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20216 | forever426 | 탐사 (KOI13_probe) | C11 | 2081 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |