#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 < 1; 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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
256 KB |
Output is correct |
2 |
Incorrect |
8 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
256 KB |
Output is correct |
2 |
Incorrect |
8 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |