# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
889817 |
2023-12-20T07:29:46 Z |
vjudge1 |
Chorus (JOI23_chorus) |
C++17 |
|
0 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int mod = 998244353;
const int N = 1e5;
int ans = INT_MAX;
int n, k;
vector<int> p;
string s;
deque<int> A, B, A1, B1;
vector<int> vec;
void f(int cursum, int last){
if(p.size() > k or cursum > n) return;
if(cursum == n){
if(p.size() == k){
int res = 0;
for(int sz : p){
int x = sz;
vec.clear();
while(x--){
vec.push_back(A.front());
A.pop_front();
}
x = sz;
while(x--){
int el = B.front();
B.pop_front();
for(int el1 : vec){
if(el1 > el){
res++;
}
}
}
}
A = A1, B = B1;
ans = min(ans, res);
return;
}
return;
}
for(int i = 1;i + cursum <= n; i++){
p.push_back(i);
f(cursum + i, i);
p.pop_back();
}
}
/*
5 2
AABABABBAB
*/
/*
10 3
ABABBBBABBABABABAAAA
* */
/*
5 3
AABABABBAB
* */
signed main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k >> s;
for(int i = 0;i < 2*n; i++){
if(s[i] == 'A'){
A.push_back(i);
}else B.push_back(i);
}
A1 = A, B1 = B;
f(0, 1);
cout << ans;
return 0;
}
Compilation message
chorus.cpp: In function 'void f(long long int, long long int)':
chorus.cpp:19:14: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
19 | if(p.size() > k or cursum > n) return;
| ~~~~~~~~~^~~
chorus.cpp:21:15: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
21 | if(p.size() == k){
| ~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |