Please sign in first.
Submission #31742190
Source Code Expand
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = 3.14159265359;
const ll INF = 1LL << 60;
int
check(string s, int offset)
{
int len = s.length();
if (len % offset != 0){ return (1 << 30); }
char t[offset];
int d['z'-'a'+1];
for (int i = 0; i < offset; i++){
int maxi = 0;
for (int j = 0; j < len / offset; j++){
char c = s[j*offset + i];
d[c-'a']++;
if (d[c-'a'] > maxi){
maxi = d[c-'a'];
t[i] = c;
}
}
}
int ans = 0;
for (int i = 0; i < len; i++){
if (s[i] != t[i%offset]){
ans++;
}
}
return ans;
}
int main()
{
int n, k;
string s;
cin >> n >> k >> s;
for (int i = 1; i <= n; i++){
if (n%i != 0) continue;
if (check(s, i) <= k){
cout << i << endl;
break;
}
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Right String |
| User | unnohideyuki |
| Language | C++ (GCC 9.2.1) |
| Score | 0 |
| Code Size | 932 Byte |
| Status | WA |
| Exec Time | 7 ms |
| Memory | 3684 KiB |
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 300 | ||||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt, example_02.txt |
| All | example_00.txt, example_01.txt, example_02.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | WA | 7 ms | 3612 KiB |
| example_01.txt | AC | 2 ms | 3620 KiB |
| example_02.txt | WA | 2 ms | 3636 KiB |
| test_00.txt | AC | 2 ms | 3468 KiB |
| test_01.txt | AC | 5 ms | 3648 KiB |
| test_02.txt | AC | 2 ms | 3644 KiB |
| test_03.txt | WA | 2 ms | 3648 KiB |
| test_04.txt | AC | 2 ms | 3544 KiB |
| test_05.txt | AC | 2 ms | 3536 KiB |
| test_06.txt | AC | 5 ms | 3608 KiB |
| test_07.txt | WA | 2 ms | 3580 KiB |
| test_08.txt | AC | 2 ms | 3632 KiB |
| test_09.txt | AC | 3 ms | 3648 KiB |
| test_10.txt | WA | 2 ms | 3680 KiB |
| test_11.txt | AC | 2 ms | 3488 KiB |
| test_12.txt | WA | 2 ms | 3540 KiB |
| test_13.txt | AC | 2 ms | 3540 KiB |
| test_14.txt | AC | 2 ms | 3588 KiB |
| test_15.txt | AC | 2 ms | 3680 KiB |
| test_16.txt | AC | 2 ms | 3684 KiB |
| test_17.txt | AC | 2 ms | 3628 KiB |
| test_18.txt | AC | 2 ms | 3644 KiB |
| test_19.txt | AC | 2 ms | 3484 KiB |
| test_20.txt | AC | 2 ms | 3536 KiB |
| test_21.txt | WA | 2 ms | 3676 KiB |
| test_22.txt | WA | 2 ms | 3624 KiB |
| test_23.txt | AC | 2 ms | 3632 KiB |
| test_24.txt | WA | 2 ms | 3640 KiB |
| test_25.txt | WA | 2 ms | 3544 KiB |
| test_26.txt | WA | 2 ms | 3624 KiB |
| test_27.txt | WA | 2 ms | 3680 KiB |
| test_28.txt | WA | 2 ms | 3536 KiB |
| test_29.txt | WA | 2 ms | 3580 KiB |
| test_30.txt | WA | 2 ms | 3528 KiB |