Submission #1230150

#TimeUsernameProblemLanguageResultExecution timeMemory
1230150hainam2k9Lamps (JOI19_lamps)C++20
100 / 100
48 ms14116 KiB
#include <bits/stdc++.h> #define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0) #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout) #define ll long long #define ull unsigned long long #define i128 __int128 #define db long double #define sz(a) ((int)(a).size()) #define pb emplace_back #define pf emplace_front #define pob pop_back #define pof pop_front #define lb lower_bound #define ub upper_bound #define fi first #define se second #define ins emplace #define mp make_pair using namespace std; const int MOD = 1e9+7, MAXN = 1e6+5; const string NAME = ""; int n,dp[MAXN][3]; char a[MAXN],b[MAXN]; int main() { tt; if(fopen((NAME + ".INP").c_str(), "r")) fo; cin >> n; for(int i = 1; i<=n; ++i) cin >> a[i]; for(int i = 1; i<=n; ++i) cin >> b[i]; memset(dp,0x3f,sizeof(dp)); dp[0][0]=0; for(int i = 1; i<=n; ++i){ for(int j = 0; j<3; ++j) for(int k = 0; k<3; ++k){ if(j+k==3) continue; dp[i][j]=min(dp[i][j],dp[i-1][k]+(j>0&&k==0)+((i==1||(k==0 ? a[i-1] : k+47)==b[i-1])&&(j==0 ? a[i] : j+47)!=b[i])); } } cout << min({dp[n][0],dp[n][1],dp[n][2]}); }

Compilation message (stderr)

lamp.cpp: In function 'int main()':
lamp.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lamp.cpp:27:45: note: in expansion of macro 'fo'
   27 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
lamp.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lamp.cpp:27:45: note: in expansion of macro 'fo'
   27 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...