# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1003702 |
2024-06-20T15:51:00 Z |
Hanksburger |
Lamps (JOI19_lamps) |
C++17 |
|
14 ms |
8868 KB |
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > tmp;
vector<int> vec;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, sz, state=0, ans=0;
cin >> n;
string s, t;
cin >> s >> t;
for (int i=0; i<n; i++)
{
if (i && t[i]!=t[i-1])
{
vec.push_back(state);
state=0;
}
if (state%2==0 && s[i]==t[i])
state++;
else if (state<2 && s[i]!=t[i])
state+=2;
}
vec.push_back(state);
sz=vec.size();
for (int i=0; i<sz; i++)
{
if (vec[i]==1)
{
int sz0=tmp.size(), cnt=0;
for (int j=0; j<sz0; j++)
{
//cout << tmp[j].first << ' ' << tmp[j].second << '\n';
if (tmp[j].first==3 || tmp[j].second==1 || (tmp[j].second==2 && j && j<=sz0-2) || (tmp[j].second==3 && cnt%2==0 && j && j<=sz0-2))
cnt+=tmp[j].second;
else
{
if (!cnt)
ans++;
else
ans+=cnt/2+2;
cnt=0;
}
}
if (cnt)
ans+=cnt/2+1;
tmp.clear();
}
else if (tmp.empty() || vec[i]!=tmp.back().first)
tmp.push_back({vec[i], 1});
else
tmp.back().second++;
}
int sz0=tmp.size(), cnt=0;
for (int j=0; j<sz0; j++)
{
//cout << tmp[j].first << ' ' << tmp[j].second << '\n';
if (tmp[j].first==3 || tmp[j].second==1 || (tmp[j].second==2 && j && j<=sz0-2) || (tmp[j].second==3 && cnt%2==0 && j && j<=sz0-2))
cnt+=tmp[j].second;
else
{
if (!cnt)
ans++;
else
ans+=cnt/2+2;
cnt=0;
}
}
if (cnt)
ans+=cnt/2+1;
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
4344 KB |
Output is correct |
8 |
Correct |
13 ms |
8868 KB |
Output is correct |
9 |
Correct |
14 ms |
8864 KB |
Output is correct |
10 |
Correct |
13 ms |
8800 KB |
Output is correct |
11 |
Correct |
13 ms |
8796 KB |
Output is correct |
12 |
Correct |
5 ms |
4504 KB |
Output is correct |
13 |
Correct |
5 ms |
4344 KB |
Output is correct |
14 |
Correct |
5 ms |
4528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |