제출 #70644

#제출 시각아이디문제언어결과실행 시간메모리
70644Navick저울 (IOI15_scales)C++17
0 / 100
4 ms628 KiB
#include "scales.h"
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define pii pair<int, int>

using namespace std;

typedef long long ll;

const int maxN = 6;

vector <int> t;
int ans[maxN];

void init(int T) {
	/* ... */
}

void orderCoins() {

	int a = getHeaviest(1, 2, 3);
	int b = getHeaviest(4, 5, 6);

	t.resize(0);
	for (int i=4; i<=6; i++)
		if(i != b) t.pb(i);

	int a1 = getHeaviest(a, t[0], t[1]);

	if(a1 >= 4)
	{
		ans[0] = b;
		ans[1] = a1;

		int c = 15;
		for (int i=4; i<=6; i++)
			if(i == b || i == a1) c -= i;

		t.resize(0);
		for (int i=1; i<=3; i++)
			if(i != a) t.pb(i);

		int g = getHeaviest(c, t[0], t[1]);

		if(g == c)
		{
			ans[3] = getLightest(ans[0], a, c);
			ans[2] = a + c - ans[3];

			ans[5] = getLightest(ans[0], t[0], t[1]);
			ans[4] = t[0] + t[1] - ans[5];

			reverse(ans, ans + maxN);
			answer(ans);
			return ;
		}else
		{
			ans[2] = a;
			ans[3] = g;
			int oth = t[0] + t[1] - g;

			ans[5] = getLightest(ans[0], c, oth);
			ans[4] = oth + c - ans[5];

			reverse(ans, ans + maxN);
			answer(ans);
			return ;

		}
	}else
	{
		int c = -1;
		for (int i=1; i<=3; i++)
			if(i != a) c = i;

		int md = getMedian(a, b, c);

		if(md != c)
		{
			ans[0] = a + b - md;
			ans[1] = a + b - ans[0];

			t.resize(0);
			for (int i=1; i<=6; i++)
				if(i != a && i != b) t.pb(i);
			int c1 = getHeaviest(t[0], t[1], t[2]);

			int r = t[3];

			t.resize(0);
			for (int i=1; i<=6; i++)
				if(i != a && i != b && i != c1) t.pb(i);

			int c2 = getLightest(t[0], t[1], t[2]);

			if(c2 != r)
			{
				ans[5] = c2;

				t.resize(0);
				for (int i=1; i<=6; i++)
					if(i != a && i != b && i != c2 && i != r && i != c1) t.pb(i);

				int md2 = getMedian(t[0], c1, r);

				if(md2 == c1) ans[2] = r, ans[3] = c1, ans[4] = t[0];
				else if(md2 == t[0]) ans[2] = c1, ans[3] = t[0], ans[4] = r;
				else ans[2] = c1, ans[3] = r, ans[4] = t[0];

			}else
			{
				ans[5] = c2;
				ans[2] = c1;
				t.resize(0);
				for (int i=1; i<=6; i++) 
					if(i != a && i != b && i != c1 && i != c2) t.pb(i);

				int g = getLightest(c1, t[0], t[1]);
				ans[4] = g;
				ans[3] = t[0] + t[1] - g;

			}
			reverse(ans, ans + maxN);
			answer(ans);
		}else
		{
			ans[0] = a;
			t.resize(0);
			for (int i=1; i<=3; i++)
				if(i != a) t.pb(i);
			ans[1] = getMedian(a, t[0], t[1]);

			int r = t[0] + t[1] - ans[1];

			t.resize(0);
			for (int i=4; i<=6; i++)
				if(i != b) t.pb(i);

			int c2 = getLightest(r, t[0], t[1]);
			ans[5] = c2;

			if(c2 == r)
			{
				ans[4] = getLightest(b, t[0], t[1]);
				ans[3] = t[0] + t[1] - ans[4];
				ans[2] = b;
			}else
			{
				int oth = t[0] + t[1] - c2;
				int md2 = getMedian(b, r, oth);
				if(md2 == b) ans[2] = r, ans[3] = b, ans[4] = oth;
				else if(md2 == r) ans[2] = b, ans[3] = r, ans[4] = oth;
				else ans[2] = b, ans[3] = oth, ans[4] = r;
			}

			reverse(ans, ans + maxN);
			answer(ans);
			return ;
		}
	}
}

컴파일 시 표준 에러 (stderr) 메시지

In file included from grader.c:2:0:
graderlib.c: In function 'void answer(int*)':
graderlib.c:53:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (_ghksjhdfkae19ga_ > 1) 
     ^~
graderlib.c:56:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  for (i = 0; i < 6; i++) {
  ^~~
scales.cpp: In function 'void init(int)':
scales.cpp:18:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
#Verdict Execution timeMemoryGrader output
Fetching results...