Submission #1186

# Submission time Handle Problem Language Result Execution time Memory
1186 2013-06-29T12:01:59 Z gs13068 탐사 (KOI13_probe) C++
14.63 / 19
2000 ms 376 KB
#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]=false;
	for(i=x;i<=n;i++)max[i]--;
	if(check())backtracking(x+1);
	ans[x]=true;
	for(i=x;i<=n;i++){min[i]++;max[i]++;}
	if(check())backtracking(x+1);
	for(i=x;i<=n;i++)min[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

probe.cpp: In function 'int main()':
probe.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
probe.cpp:45:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=0;i<m;i++)scanf("%d%d%d",&a[i],&b[i],&c[i]);
                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 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 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 88 ms 352 KB Output is correct
# 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 2 ms 376 KB Output is correct
4 Correct 728 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 352 KB Output is correct
2 Correct 1742 ms 356 KB Output is correct
3 Execution timed out 2057 ms 256 KB Time limit exceeded
4 Halted 0 ms 0 KB -