Submission #147841

#TimeUsernameProblemLanguageResultExecution timeMemory
147841Lovely Trick (#201)백점을 받아랏! (FXCUP4_hundred)C++17
100 / 100
9 ms384 KiB
#include "hundred.h" using namespace std; int diff[102]; string GetHundredPoints(int A, int B, int C) { string now = string(A, 'A') + string(B, 'B') + string(C, 'C'); int original = Mark(now); int neq = -1; for(int i = 1; i < 100; i++){ if(now[i] != now[0]){ neq = i; break; } } if(neq == -1) return now; for(int i = neq; i < 100; i++){ swap(now[0], now[i]); int v = Mark(now); swap(now[0], now[i]); int d = v - original; if(d == -2 || d == 1){ diff[i] = now[i] - now[0]; } if(d == -1 || d == 2){ diff[i] = now[0] - now[i]; } } for(int i = 1; i < neq; i++){ swap(now[i], now[neq]); int v = Mark(now); swap(now[i], now[neq]); int d = v - original; if(d == -2 || d == 1){ diff[i] = diff[neq] + now[i] - now[neq]; } if(d == -1 || d == 2){ diff[i] = diff[neq] + now[neq] - now[i]; } if(d == 0){ diff[i] = diff[neq]; } } int c0 = 0, c1 = 0, c2 = 0; for(int i = 0; i < 100; i++){ int &d = diff[i]; while(d < 0) d += 3; while(d > 2) d -= 3; (d == 0 ? c0 : d == 1 ? c1 : c2)++; } string ans = string(); if(c0 == A && c1 == B && c2 == C){ for(int i = 0; i < 100; i++) ans += (diff[i] == 0 ? 'A' : diff[i] == 1 ? 'B' : 'C'); } if(c0 == B && c1 == C && c2 == A){ for(int i = 0; i < 100; i++) ans += (diff[i] == 0 ? 'B' : diff[i] == 1 ? 'C' : 'A'); } if(c0 == C && c1 == A && c2 == B){ for(int i = 0; i < 100; i++) ans += (diff[i] == 0 ? 'C' : diff[i] == 1 ? 'A' : 'B'); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...