Submission #210746

#TimeUsernameProblemLanguageResultExecution timeMemory
210746mhy908Lamps (JOI19_lamps)C++14
0 / 100
5 ms376 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define F first #define S second #define all(x) x.begin(), x.end() #define sortvec(x) sort(all(x)) #define compress(x) x.erase(unique(all(x)), x.end()) using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; typedef pair<int, LL> pil; typedef pair<LL, int> pli; const LL llinf=1987654321987654321; const int inf=2000000000; int dp[1000010][4]; int n; char str1[1000010], str2[1000010]; char alter(char c, int qu){ if(qu==1)return '0'; if(qu==2)return '1'; return c; } int main(){ scanf("%d", &n); scanf("%s", str1+1); scanf("%s", str2+1); for(int i=1; i<=n; i++)dp[i][1]=dp[i][2]=dp[i][3]=inf; for(int i=1; i<=n; i++){ for(int j=1; j<=3; j++){ for(int k=1; k<=3; k++){ int temp=dp[i-1][j]; if(j!=k&&k!=2)temp++; if((i==1||alter(str1[i-1], j)==str2[i-1])&&alter(str1[i], k)!=str2[i])temp++; dp[i][k]=min(dp[i][k], temp); } } } printf("%d", min(min(dp[n][1], dp[n][2]), dp[n][3])); }

Compilation message (stderr)

lamp.cpp: In function 'int main()':
lamp.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
lamp.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", str1+1);
     ~~~~~^~~~~~~~~~~~~~
lamp.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", str2+1);
     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...