Submission #147712

# Submission time Handle Problem Language Result Execution time Memory
147712 2019-08-30T13:13:24 Z pichulia,koosaga,ainta(#3658, pichulia) Get Hundred Points! (FXCUP4_hundred) C++17
0 / 100
7 ms 256 KB
#include "hundred.h"
static std::string flip(std::string a)
{
	std::string b;
	b.resize(100);
	for (int i = 0; i < 99; i++)
	{
		b[i+1] = a[i];
	}
	b[0] = a[99];
	return b;
}
std::string GetHundredPoints(int A, int B, int C) {
	std::string res;
	res.resize(100);
	int i, j, k;
	for (i = 0; i < A; i++)res[i] = 'A';
	for (i = 0; i < B; i++)res[A + i] = 'B';
	for (i = 0; i < C; i++)res[A + B + i] = 'C';

	int score[100];
	for (i = 0; i < 100; i++)
	{
		score[i] = Mark(res);
		res = flip(res);
	}

	int valid[100][3];
	for (i = 0; i < 100; i++) {
		valid[i][0] = valid[i][1] = valid[i][2] = 0;
	}

	int dif;
	int offset = 0;
	for(offset=0; offset<100; offset++)
	{
		dif = (score[(offset + 1)%100] - score[offset]);
		i = (offset + A) % 100;
		j = (offset + A + B) % 100;
		k = (offset + A + B + C) % 100;

		for(int ti=0;ti<3;ti++)
			for(int tj=0; tj<3; tj++)
				for (int tk = 0; tk < 3; tk++)
				{
					{
						int pi = (ti+1)%3;
						int pj = (tj) % 3;
						int pk = (tk + 2) % 3;
						if (pi == 2)pi = -1; if (pj == 2)pj = -1; if (pk == 2)pk = -1;
						if (pi + pj + pk == dif) {
							valid[i][ti] |= 1;
							valid[j][tj] |= 2;
							valid[k][tk] |= 4;
						}
					}
				}
	}

	for (i = 0; i < 100; i++)
	{
		int cnt = 0;
		int ri = 0;
		for (j = 0; j < 3; j++) {
			if (valid[i][j] == 7)
			{
				cnt++;
				ri = j;
			}
		}
		res[i] = ri + 'A';
	}

	return res;
}

Compilation message

hundred.cpp: In function 'std::__cxx11::string GetHundredPoints(int, int, int)':
hundred.cpp:50:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
       if (pi == 2)pi = -1; if (pj == 2)pj = -1; if (pk == 2)pk = -1;
       ^~
hundred.cpp:50:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
       if (pi == 2)pi = -1; if (pj == 2)pj = -1; if (pk == 2)pk = -1;
                            ^~
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -