답안 #136371

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
136371 2019-07-25T07:56:59 Z 조승현(#3264) Meandian (CEOI06_meandian) C++14
100 / 100
8 ms 376 KB
#include "libmean.h"
#include<cstdio>
#include<algorithm>
using namespace std;

int arr[100];
int Go(int *w) {
	int i, T[5], j;
	for (i = 0; i < 5; i++) {
		T[i] = Meandian(w[(i + 1) % 5], w[(i + 2) % 5], w[(i + 3) % 5], w[(i + 4) % 5]);
	}
	int pv;
	for (i = 0; i < 5; i++) {
		for (j = 0; j < 5; j++) {
			if (i != j && T[i] == T[j])break;
		}
		if (j == 5)pv = i;
	}
	sort(T, T + 5);
	arr[w[pv]-1] = T[1] + T[3] - T[2];

	return w[pv];
}
int main(void)
{
	int i, n;
	int foo, bar, quux;
	n = Init();
	for (i = 0; i < n; i++)arr[i] = -1;
	int w[5];
	for (i = 1; i <= 4; i++)w[i - 1] = i;
	int pv = 4;
	for (i = 5; i <= n; i++) {
		w[pv] = i;
		int z = Go(w);
		for (int j = 0; j < 5; j++)if (w[j] == z)pv = j;
	}
	Solution(arr);
}

Compilation message

meandian.cpp: In function 'int main()':
meandian.cpp:27:6: warning: unused variable 'foo' [-Wunused-variable]
  int foo, bar, quux;
      ^~~
meandian.cpp:27:11: warning: unused variable 'bar' [-Wunused-variable]
  int foo, bar, quux;
           ^~~
meandian.cpp:27:16: warning: unused variable 'quux' [-Wunused-variable]
  int foo, bar, quux;
                ^~~~
meandian.cpp: In function 'int Go(int*)':
meandian.cpp:20:10: warning: 'pv' may be used uninitialized in this function [-Wmaybe-uninitialized]
  arr[w[pv]-1] = T[1] + T[3] - T[2];
          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 248 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 248 KB Output is correct
8 Correct 6 ms 248 KB Output is correct
9 Correct 7 ms 248 KB Output is correct
10 Correct 8 ms 376 KB Output is correct