# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1185 | gs13068 | 탐사 (KOI13_probe) | C++98 | 2067 ms | 380 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<cstdio>
#include<cstdlib>
bool ans[41];
int max[41];
int min[41];
int a[1000];
int b[1000];
int c[1000];
int n,m;
inline bool check()
{
int i;
for(i=0;i<m;i++)
{
if(max[b[i]]-max[a[i]-1]<c[i])return false;
if(min[b[i]]-min[a[i]-1]>c[i])return false;
}
return true;
}
inline void backtracking(int x)
{
int i;
if(x>n)
{
for(i=1;i<=n;i++)printf(ans[i]?"#":"-");
exit(0);
}
ans[x]=true;
for(i=x;i<=n;i++)min[i]++;
if(check())backtracking(x+1);
ans[x]=false;
for(i=x;i<=n;i++){min[i]--;max[i]--;}
if(check())backtracking(x+1);
for(i=x;i<=n;i++)max[i]++;
}
int main()
{
int i;
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++)max[i]=i;
for(i=0;i<m;i++)scanf("%d%d%d",&a[i],&b[i],&c[i]);
backtracking(1);
puts("NONE");
}
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... |