Submission #427979

#TimeUsernameProblemLanguageResultExecution timeMemory
427979juggernautLamps (JOI19_lamps)C++17
6 / 100
479 ms21872 KiB
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} typedef long long ll; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef IOI2021SG #define printl(args...)printf(args) #else #define printl(args...)((void)0) #endif int n; string a,b; int dp[262144]; int go(int mask){ if(~dp[mask])return dp[mask]; dp[mask]=1e9; for(int i=0;i<n;i++){ int A=mask; int B=mask; int C=mask; for(int j=i;j<n;j++){ if(mask>>j&1)A^=(1<<j); else B^=(1<<j); C^=(1<<j); umin(dp[mask],go(A)+1); umin(dp[mask],go(B)+1); umin(dp[mask],go(C)+1); } } return dp[mask]; } int main(){ memset(dp,-1,sizeof dp); cin>>n>>b>>a; int cnt=0; int dest=0; for(int i=0;i<n;i++)cnt|=((a[i]=='1')<<i); for(int i=0;i<n;i++)dest|=((b[i]=='1')<<i); dp[cnt]=0; cout<<go(dest); }

Compilation message (stderr)

lamp.cpp: In function 'void usaco(std::string)':
lamp.cpp:5:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lamp.cpp:5:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...