Submission #432727

#TimeUsernameProblemLanguageResultExecution timeMemory
432727juggernautMiners (IOI07_miners)C++17
100 / 100
165 ms512 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 char s[100005]; int dp[2][16][16]; int cost[64]; int mx; void add(char ch){ int id; if(ch=='M')id=1; if(ch=='B')id=2; if(ch=='F')id=3; for(int i=0;i<16;i++) for(int j=0;j<16;j++){ int x=i; x<<=2; x+=id; umax(dp[1][x&15][j],dp[0][i][j]+cost[x]); umax(mx,dp[1][x&15][j]); x=j; x<<=2; x+=id; umax(dp[1][i][x&15],dp[0][i][j]+cost[x]); umax(mx,dp[1][i][x&15]); } for(int i=0;i<16;i++) for(int j=0;j<16;j++){ dp[0][i][j]=dp[1][i][j]; dp[1][i][j]=-1e9; } } int main(){ for(int x=0;x<2;x++) for(int i=0;i<16;i++) for(int j=0;j<16;j++)dp[x][i][j]=-1e9; dp[0][0][0]=0; for(int i=0;i<64;i++){ int tmp=i; int x=tmp&3; tmp>>=2; int y=tmp&3; tmp>>=2; int z=tmp&3; set<int>st; st.insert(x); st.insert(y); st.insert(z); st.erase(0); cost[i]=st.size(); } int n; scanf("%d",&n); scanf("%s",&s); for(int i=0;i<n;i++)add(s[i]); printf("%d",mx); }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:69:13: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[100005]' [-Wformat=]
   69 |     scanf("%s",&s);
      |            ~^  ~~
      |             |  |
      |             |  char (*)[100005]
      |             char*
miners.cpp: In function 'void usaco(std::string)':
miners.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);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
miners.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);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
miners.cpp: In function 'int main()':
miners.cpp:68:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
miners.cpp:69:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |     scanf("%s",&s);
      |     ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...