답안 #147757

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147757 2019-08-30T14:52:39 Z gina(#3662, imyujin) 백점을 받아랏! (FXCUP4_hundred) C++17
33 / 100
8 ms 384 KB
#include "hundred.h"
#include <bits/stdc++.h>
using namespace std;

string solve(int An, int Bn, char A, char B) {
	string ans;
	for(int i = 0; i < 100; i++) ans.push_back(B);
	if(An == 0) return ans;

	int res[100];
	string s;
	for(int i = 0; i < An - 1; i++) s.push_back(A);
	for(int i = An - 1; i < 100; i++) s.push_back(B);
	for(int i = 50; i < 100; i++) {
		s[i] = A;
		res[i] = Mark(s);
		s[i] = B;
	}
	int mn = 100, mx = 0;
	for(int i = 50; i < 100; i++) {
		mn = min(mn, res[i]);
		mx = max(mx, res[i]);
	}
	for(int i = 50; i < 100; i++) if(res[i] > mn) ans[i] = A;
	if(mn == mx && res[50] == 1) for(int i = 50; i < 100; i++) ans[i] = A;

	for(int i = 0; i < Bn + 1; i++) s[i] = B;
	for(int i = Bn + 1; i < 100; i++) s[i] = A;
	for(int i = 0; i < 50; i++) {
		s[i] = A;
		res[i] = Mark(s);
		s[i] = B;
	}
	mn = 100, mx = 0;
	for(int i = 0; i < 50; i++) mn = min(mn, res[i]);
	for(int i = 0; i < 50; i++) if(res[i] > mn) ans[i] = A;
	if(mn == mx && res[0] == 1) for(int i = 0; i < 50; i++) ans[i] = A;
	return ans;
}

string solve2(int An, int Bn, char A, char B) {
	return An < Bn ? solve(An, Bn, A, B) : solve(Bn, An, B, A);
}

int same(char X[], char Y[]) {
	int cnt = 0;
	for(int i = 0; i < 3; i++) if(X[i] == Y[i]) cnt++;
	return cnt;
}

void check(char X[3][4]) {
	int cnt[64];
	char c[4];
	for(c[0] = 'A'; c[0] <= 'C'; c[0]++) for(c[1] = 'A'; c[1] <= 'C'; c[1]++) for(c[2] = 'A'; c[2] <= 'C'; c[2]++) {
		cnt[same(X[0], c) * 16 + same(X[1], c) + same(X[2], c)]++;
	}
	bool b = true;
	for(int i = 0; i < 64; i++) if(cnt[i] > 1) b = false;
	if(b) printf("CORRECT\n");
	else printf("WRONG\n");
}

string GetHundredPoints(int A, int B, int C) {
	if(!A) return solve2(B, C, 'B', 'C');
	if(!B) return solve2(A, C, 'A', 'C');
	if(!C) return solve2(A, B, 'A', 'B');

	return A < B ? solve(A, B, 'A', 'B') : solve(B, A, 'B', 'A');
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 256 KB Output is correct
2 Correct 8 ms 344 KB Output is correct
3 Correct 7 ms 344 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 7 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 256 KB Output is correct
2 Correct 8 ms 344 KB Output is correct
3 Correct 7 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 Incorrect 6 ms 384 KB Output isn't correct
7 Halted 0 ms 0 KB -