ログインしてください。
提出 #32485998
ソースコード 拡げる
use proconio::{input, marker::Chars};
use superslice::Ext;
fn main() {
input! {
n: usize,
s: Chars
};
let f = |c: char| -> usize { (c as u8 - b'A') as usize };
let t = vec![&s[0..n], &s[n..2 * n], &s[2 * n..3 * n]];
let mut count = vec![vec![0; 3]; 3];
for i in 0..3 {
for ch in t[i].iter().copied() {
count[i][f(ch)] += 1;
}
}
let mut group = 1;
let mut ans = vec![0; 3 * n];
let mut chars = "ABC".chars().collect::<Vec<char>>();
loop {
let mut min = n;
for i in 0..3 {
let ch = chars[i];
min = min.min(count[i][f(ch)]);
}
for i in 0..3 {
let ch = chars[i];
count[i][f(ch)] -= min;
}
for i in 0..3 {
let mut used = 0;
for j in 0..n {
if used < min && t[i][j] == chars[i] && ans[i * n + j] == 0 {
ans[i * n + j] = group;
used += 1;
}
}
}
if min > 0 {
group += 1;
}
if !chars.next_permutation() {
break;
}
}
let ans = ans
.into_iter()
.map(|i| (i as u8 + b'0') as char)
.collect::<String>();
println!("{}", ans);
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - ABC Identity |
| ユーザ | bouzuya |
| 言語 | Rust (1.42.0) |
| 得点 | 400 |
| コード長 | 1313 Byte |
| 結果 | AC |
| 実行時間 | 34 ms |
| メモリ | 7996 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 01.txt, 02.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01.txt | AC | 7 ms | 2040 KiB |
| 02.txt | AC | 2 ms | 2064 KiB |
| 03.txt | AC | 1 ms | 2096 KiB |
| 04.txt | AC | 1 ms | 1976 KiB |
| 05.txt | AC | 1 ms | 2064 KiB |
| 06.txt | AC | 1 ms | 2112 KiB |
| 07.txt | AC | 1 ms | 2088 KiB |
| 08.txt | AC | 1 ms | 1944 KiB |
| 09.txt | AC | 1 ms | 1944 KiB |
| 10.txt | AC | 1 ms | 1944 KiB |
| 11.txt | AC | 1 ms | 2112 KiB |
| 12.txt | AC | 1 ms | 1984 KiB |
| 13.txt | AC | 1 ms | 1980 KiB |
| 14.txt | AC | 1 ms | 2112 KiB |
| 15.txt | AC | 1 ms | 1940 KiB |
| 16.txt | AC | 1 ms | 2168 KiB |
| 17.txt | AC | 1 ms | 2172 KiB |
| 18.txt | AC | 3 ms | 2108 KiB |
| 19.txt | AC | 2 ms | 2092 KiB |
| 20.txt | AC | 2 ms | 2116 KiB |
| 21.txt | AC | 2 ms | 2112 KiB |
| 22.txt | AC | 2 ms | 2116 KiB |
| 23.txt | AC | 2 ms | 2152 KiB |
| 24.txt | AC | 2 ms | 1996 KiB |
| 25.txt | AC | 2 ms | 2080 KiB |
| 26.txt | AC | 31 ms | 7888 KiB |
| 27.txt | AC | 33 ms | 7844 KiB |
| 28.txt | AC | 29 ms | 7816 KiB |
| 29.txt | AC | 29 ms | 7864 KiB |
| 30.txt | AC | 29 ms | 7884 KiB |
| 31.txt | AC | 29 ms | 7852 KiB |
| 32.txt | AC | 31 ms | 7864 KiB |
| 33.txt | AC | 32 ms | 7892 KiB |
| 34.txt | AC | 29 ms | 7864 KiB |
| 35.txt | AC | 30 ms | 7816 KiB |
| 36.txt | AC | 33 ms | 7872 KiB |
| 37.txt | AC | 29 ms | 7936 KiB |
| 38.txt | AC | 34 ms | 7888 KiB |
| 39.txt | AC | 32 ms | 7996 KiB |
| 40.txt | AC | 32 ms | 7884 KiB |
| 41.txt | AC | 32 ms | 7824 KiB |
| 42.txt | AC | 32 ms | 7896 KiB |
| 43.txt | AC | 29 ms | 7788 KiB |
| 44.txt | AC | 30 ms | 7788 KiB |
| 45.txt | AC | 31 ms | 7764 KiB |
| 46.txt | AC | 30 ms | 7920 KiB |