QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#132246 | #1403. JOIOJI | SaKaTa | 0 | 1ms | 3720kb | C++14 | 927b | 2023-07-29 09:44:54 | 2023-07-29 09:44:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 9 + 1e6;
const int oo = 7 + 1e9;
map<pair<int, int>, int> m;
void SaKaTa()
{
int n;
scanf("%d", &n);
string s;
cin >> s;
pair<int, int> FIND(0, 0);
m[FIND] = -1;
int ans = 0;
for (int i = 0; i < s.size(); i++)
{
if (s[i] == 'J') ++FIND.first, ++FIND.second;
else if (s[i] == 'O') --FIND.first;
else --FIND.second;
if (m.count(FIND)) ans = max(ans, i - m[FIND]);
else m[FIND] = i;
}
printf("%d", ans);
}
int32_t main()
{
#define TASKNAME "FINDS"
cin.tie(0)->sync_with_stdio(0);
if (fopen(TASKNAME ".inp", "r"))
{
freopen(TASKNAME ".inp", "r", stdin);
freopen(TASKNAME ".out", "w", stdout);
}
int testcase = 1;
// scanf("%d", &testcase);
while (testcase--)
SaKaTa();
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3720kb
input:
50 IOJJJJIIIOOJOOOIOIJIJIOOOOJJOOOJIOIJIOIJIOIIIJOJJJ
output:
0
result:
wrong answer 1st lines differ - expected: '33', found: '0'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%