| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1003694 | Hanksburger | Lamps (JOI19_lamps) | C++17 | 15 ms | 10556 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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++)
{
if (tmp[j].first==3 || tmp[j].second==1 || tmp[j].second==2 || (tmp[j].second==3 && cnt%2==0))
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++)
{
if (tmp[j].first==3 || tmp[j].second==1 || tmp[j].second==2 || (tmp[j].second==3 && cnt%2==0))
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 |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
