# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
148279 | ksun48 (#201) | 백점을 받아랏! (FXCUP4_hundred) | C++17 | 8 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hundred.h"
#include <bits/stdc++.h>
std::string GetHundredPoints(int A, int B, int C) {
using namespace std;
assert(A + B + C == 100);
string str = string(A, 'A') + string(B, 'B') + string(C, 'C');
if(A == 100 || B == 100 || C == 100) return str;
string ans(A + B + C, 'A');
int value = Mark(str);
auto f = [&](int a, int b){
string new_str = str;
swap(new_str[a], new_str[b]);
int diff = (Mark(new_str) - value) * (str[b] - str[a]) % 3;
if(diff < 0) diff += 3;
ans[b] = ((ans[a] - 'A' + diff) % 3) + 'A';
};
if(A && B){
for(int i = A; i < A+B+C; i++) f(0, i);
for(int i = 1; i < A; i++) f(A, i);
} else {
for(int i = A+B; i < A+B+C; i++) f(0, i);
for(int i = 1; i < A+B; i++) f(A+B, i);
}
for(int i = 0; i < 3; i++){
map<char , int> cnt;
for(char x : ans) cnt[x] += 1;
if(cnt['A'] == A && cnt['B'] == B && cnt['C'] == C) return ans;
for(char& x : ans) x = 'A' + ((x - 'A' + 1) % 3);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |