#include "hundred.h"
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> pii;
const int N = 105;
pii par[N];
bool Test (int A, int B, int C, string R, string T, int V) {
int RA = 0, RB = 0, RC = 0;
for(int i=0;i<A+B+C;i++) {
if(R[i] == 'A') RA++;
if(R[i] == 'B') RB++;
if(R[i] == 'C') RC++;
}
if(A != RA || B != RB || C != RC) return false;
int RV = 0;
for(int i=0;i<A+B+C;i++) {
if(R[i] == T[i]) RV++;
}
return (V == RV);
}
string GetHundredPoints(int _A, int _B, int _C) {
int cnt[3] = {_A, _B, _C};
string def;
for(int i=0;i<3;i++) {
if(!cnt[i]) continue;
def.push_back('A'+i);
cnt[i]--;
}
for(int i=0;i<3;i++) {
while(cnt[i]--) {
def.push_back('A'+i);
}
}
int dv = Mark(def);
for(int i=_A+_B+_C-1;i;i--) {
int j;
for(j=0;def[i]==def[j];j++);
swap(def[i], def[j]);
int T = Mark(def);
swap(def[i], def[j]);
par[i] = {j, T - dv};
}
for(int k=0;k<3;k++) {
string R;
R.push_back('A'+k);
bool mosun = false;
for(int i=1;i<_A+_B+_C;i++) {
int P, Q;
tie(P, Q) = par[i];
char A = def[P], B = def[i];
char C = (3*'A'+3) - ((int)A + B);
if(Q == 2) {
if(R[P] != B) {mosun = true; break;}
R.push_back(A);
}
else if(Q == 1) {
if(R[P] == B) R.push_back(C);
else if(R[P] == C) R.push_back(A);
else {mosun = true; break;}
}
else if(Q == 0) {
R.push_back(R[P]);
}
else if(Q == -1) {
if(R[P] == A) R.push_back(C);
else if(R[P] == C) R.push_back(B);
else {mosun = true; break;}
}
else if(Q == -2) {
if(R[P] != A) {mosun = true; break;}
R.push_back(B);
}
else {mosun = true; break;}
}
if(mosun) continue;
if(Test(_A, _B, _C, R, def, dv)) return R;
}
return "";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
9 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
9 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
8 ms |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
384 KB |
Output is correct |
8 |
Correct |
6 ms |
256 KB |
Output is correct |
9 |
Correct |
7 ms |
344 KB |
Output is correct |
10 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |