# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
873967 |
2023-11-16T06:07:45 Z |
vjudge1 |
Lamps (JOI19_lamps) |
C++17 |
|
0 ms |
348 KB |
// in the name of God
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define int long long
#define fast() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define GCD(a, b) __gcd(a, b)
#define maxl *max_element
#define minl *min_element
#define ff first
#define ss second
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define mmt make_pair
#define endl '\n'
#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O4")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9 + 9, maxn = 1e5 + 10, inf = 1e18 + 1, lg = 40, pp = 4447;
vector<int> a, b;
string s1, s2;
int n;
signed main(){
fast();
cin >> n >> s1 >> s2;
bool bol = true;
for(int i = 0; i < n; ++i) if(s2[i] == 1) bol = false;
int p = 1, t;
if(s1[0] == s2[0]) t = 1;
else t = 0;
for(int i = 1; i < n; ++i){
if(s1[i] == s2[i]){
if(t == 1) p++;
else{
a.pb(p);
p = 1;
t = 1;
}
}
else{
if(t == 0) p++;
else{
a.pb(-p);
p = 1;
t = 0;
}
}
}
if(t == 0) a.pb(p);
else a.pb(-p);
int a1 = -1, a2 = 0;
for(int i : a){
if(i < 0) a1 += i;
else a2 += i;
}
a1 *= -1;
p = 1;
if(s2[0] == '1') t = 1;
else t = 0;
for(int i = 1; i < n; ++i){
if(s2[i] == '1'){
if(t == 1) p++;
else{
b.pb(-p);
p = 1;
t = 1;
}
}
else{
if(t == 1){
b.pb(p);
p = 1;
t = 0;
}
else p++;
}
}
if(t == '1') b.pb(p);
else b.pb(-p);
int b1 = (bol ? 0 : -1), b2 = (bol ? 0 : 1);
for(int i : b){
if(i < 0) b1 += i;
else b2 += i;
}
b1 *= -1;
cout << min({a1, b1, a2, b2});
}
// The sea will come out of the darkness
// and the people of the sea will return to their homes
// There is no time left. be sure!!
Compilation message
lamp.cpp:19: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
19 | #pragma GCC optimization ("O4")
|
lamp.cpp:20: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
20 | #pragma GCC optimization ("unroll-loops")
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |