| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 865928 | LittleOrange | Lamps (JOI19_lamps) | C++17 | 27 ms | 54220 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
struct obj{
ll l, r, t; // all0 all1 other
};
int main(){
ios::sync_with_stdio(0);cin.tie(0);
ll n;
string a,b;
cin >> n >> a >> b;
vector<ll> c(n+1,0);
for(ll i = 0;i<n;i++) c[i+1] = c[i] + b[i]-'0';
vector<obj> v;
ll last = -1,sm=0;
for(ll i = 0;i<n;i++){
if (a[i]!=b[i]){
if (last==-1){
last = i;
sm = b[i]-'0';
}else{
sm+=b[i]-'0';
}
}else if (last!=-1){
ll t = i-last==sm?1:(sm==0?0:2);
v.push_back({last,i-1,t});
last = -1;
}
}
if (last!=-1){
ll t = n-last==sm?1:(sm==0?0:2);
v.push_back({last,n-1,t});
last = -1;
}
ll ans = 0;
vector<obj> nw;
for(obj o : v){
if (nw.empty()) nw.push_back(o);
else{
obj z = nw.back();
if (o.t==z.t%3&&o.t!=2&&(c[o.l]-c[z.l]==(o.l-z.l)*o.t)){
nw.pop_back();
nw.push_back({z.l,o.r,o.t+3});
}else nw.push_back(o);
}
}
vector<obj> g;
for(obj o : nw){
if (g.size()<2) g.push_back(o);
else{
obj z = g[g.size()-2];
if (z.t<3&&o.t<3&&(c[o.l]-c[z.r+1])%(o.l-(z.r+1))==0) g.pop_back();
g.push_back(o);
}
}
ans += g.size();
for(obj o : g){
//cout << "[" << o.l << "," << o.r << "] " << o.t << "\n";
}
cout << ans << "\n";
}컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
