답안 #166560

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166560 2019-12-02T19:36:33 Z wmrmr 사육제 (CEOI14_carnival) C++17
0 / 100
2 ms 444 KB
#include <bits/stdc++.h>
using namespace std;
const int MAX = 160;
int n, qtd;
int cor[MAX], posCor[MAX], range[MAX];
int BB(int pos)
{
	int ini = 1, fim = range[pos];
	while(ini != fim)
	{
		int m = (ini+fim)/2;
		int num = (m-ini+1);
		printf("%d ",num+1);
		for(int i=ini;i<=m;i++) printf("%d ",posCor[i]); printf("%d ",pos);
		cout << endl;
		int resp; scanf("%d",&resp);
		if(resp == num) fim = m;
		else ini = m+1;
	}
	return ini;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		printf("%d ",i);
		for(int j=1;j<=i;j++) printf("%d ",j);
		cout << endl;
		int resp; scanf("%d",resp);
		if(resp > qtd) qtd++, posCor[qtd] = i, cor[i] = qtd;
		else range[i] = qtd;
	}
	for(int i=1;i<=n;i++)
	{
		if(cor[i]) continue;
		cor[i] = BB(i);
	}
	printf("0 ");
	for(int i=1;i<=n;i++) printf("%d ",cor[i]);
	return 0;
}

Compilation message

carnival.cpp: In function 'int BB(int)':
carnival.cpp:14:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   for(int i=ini;i<=m;i++) printf("%d ",posCor[i]); printf("%d ",pos);
   ^~~
carnival.cpp:14:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   for(int i=ini;i<=m;i++) printf("%d ",posCor[i]); printf("%d ",pos);
                                                    ^~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:30:28: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat=]
   int resp; scanf("%d",resp);
                            ^
carnival.cpp: In function 'int BB(int)':
carnival.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int resp; scanf("%d",&resp);
             ~~~~~^~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
carnival.cpp:30:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int resp; scanf("%d",resp);
             ~~~~~^~~~~~~~~~~
carnival.cpp:30:18: warning: 'resp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int resp; scanf("%d",resp);
             ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 444 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 440 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -