# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
772635 |
2023-07-04T09:18:20 Z |
hgmhc |
JOIOJI (JOI14_joioji) |
C++17 |
|
1 ms |
340 KB |
#include <bits/stdc++.h>
using namespace std; using ii = pair<int,int>; using ll = long long;
#define rep(i,a,b) for (auto i = (a); i <= (b); ++i)
#define per(i,a,b) for (auto i = (b); i >= (a); --i)
#define all(x) begin(x), end(x)
#define siz(x) int((x).size())
#define Mup(x,y) x = max(x,y)
#define mup(x,y) x = min(x,y)
#define fi first
#define se second
#define dbg(...) fprintf(stderr,__VA_ARGS__)
const int N = 2e5+3;
int n;
char s[N];
bool valid(int x) {
int c[256]{};
rep(i,1,3*x) c[int(s[i])]++;
rep(i,1,n-3*x+1) {
if (c['J'] == x and c['O'] == x and c['I'] == x) return true;
c[int(s[i])]--, c[int(s[i+3*x])]++;
}
return false;
}
int main() {
scanf("%d %s", &n, s+1);
int x = 1, y = n/3, m;
while (x <= y) {
m = (x+y)/2;
if (valid(m)) x = m+1;
else y = m-1;
}
printf("%d", 3*y);
}
Compilation message
joioji.cpp: In function 'int main()':
joioji.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
29 | scanf("%d %s", &n, s+1);
| ~~~~~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |