結果

問題 No.3728 Half and Half, and Double
コンテスト
ユーザー circled_9
提出日時 2026-09-19 16:25:48
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 847 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,149 ms
コンパイル使用メモリ 174,628 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-09-19 16:26:05
合計ジャッジ時間 3,859 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
	int N; cin>>N;
	if (N<=3){
		cout<<"-1"<<endl;
		return 0;
	}
	vector<string> S(2*N, "");
	int B = (2*N-2)*(2*N-2), A = 4*N*N-B;
	int C = (B-A)/2;
	int r = 4;
	string all = "";
	for (int i=0; i<2*N; i++) all += 'A';
	for (int i=0; i<2*N; i++){
		if (i==0||i==2*N-1){
			S[i] = all;
		} else {
			for (int j=0; j<2*N; j++){
				if (j==0||j==2*N-1) S[i] += 'A';
				else S[i] += 'B';
			}
		}
	}
	for (int i=2*N-2; i>1; i--){
		if (C<=0) break;
		if (r*(2*N-4)<C){
			S[i] = all;
			C -= 2*N-2;
			r++;
		} else {
			C -= r;
			for (int j=0; j<r; j++){
				S[i-j][2] = 'A';
			}
			for (int j=0; j<r; j++){
				for (int k=3; k<2*N-2; k++){
					if (C==0) break;
					S[i-j][k] = 'A';
					C--;
				}
			}
		}
	}
	for (int i=0; i<2*N; i++) cout<<S[i]<<endl;
}
0