Submission #147642

# Submission time Handle Problem Language Result Execution time Memory
147642 2019-08-30T10:52:13 Z 나라는괴물을막아봐(#3642, ainta) Get Hundred Points! (FXCUP4_hundred) C++17
0 / 100
6 ms 372 KB
#include "hundred.h"
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int chk[110];
string Res;

std::string GetHundredPoints(int A, int B, int C) {
	string U, S;
	U.resize(100);
	int i;
	for (i = 0; i < 100; i++) {
		chk[i] = 0;
		if (i < A)U[i] = 'A';
		else if (i < A + B)U[i] = 'B';
		else U[i] = 'C';
	}
	srand(1879);
	int Mx = -1;
	Res.resize(100);
	for (i = 0; i < 10; i++) {
		random_shuffle(U.begin(), U.end());
		int t = Mark(U);
		if (Mx < t) {
			Mx = t;
			S = U;
		}
	}
	int cur = Mx, s = 0;
	while (1) {
		vector<int>TA, TB, TC, T;
		for (i = 0; i < 100; i++) {
			if (!chk[i] && S[i] == 'A')TA.push_back(i), T.push_back(i);
			if (!chk[i] && S[i] == 'B')TB.push_back(i), T.push_back(i);
			if (!chk[i] && S[i] == 'C')TC.push_back(i), T.push_back(i);
		}
		if (TA.empty() && TB.empty()) {
			for (auto &t : TC) {
				chk[t] = 1;
				Res[t] = 'C';
			}
			break;
		}
		if (TB.empty() && TC.empty()) {
			for (auto &t : TA) {
				chk[t] = 1;
				Res[t] = 'A';
			}
			break;
		}
		if (TC.empty() && TA.empty()) {
			for (auto &t : TB) {
				chk[t] = 1;
				Res[t] = 'B';
			}
			break;
		}
		int a, b;
		while (1) {
			random_shuffle(T.begin(), T.end());
			if (S[T[0]] != S[T[1]]) {
				a = T[0];
				b = T[1];
				break;
			}
		}
		string P = S;
		swap(P[a], P[b]);
		int score = Mark(P);
		if (score - cur == 2) {
			s += 2;
			S = P;
			chk[a] = chk[b] = 1;
			Res[a] = P[a], Res[b] = P[b];
			cur = score;
		}
		if (cur - score == 2) {
			s += 2;
			chk[a] = chk[b] = 1;
			Res[a] = S[a], Res[b] = S[b];
		}
		printf("%d\n", s);
	}
	return Res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 372 KB Output isn't correct
2 Halted 0 ms 0 KB -