Submission #432353

#TimeUsernameProblemLanguageResultExecution timeMemory
432353juggernautMiners (IOI07_miners)C++17
92 / 100
1583 ms376 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][64][64]; 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<64;i++) for(int j=0;j<64;j++){ int x=i; x&=15; x<<=2; x+=id; umax(dp[1][x][j],dp[0][i][j]+cost[x]); umax(mx,dp[1][x][j]); x=j; x&=15; x<<=2; x+=id; umax(dp[1][i][x],dp[0][i][j]+cost[x]); umax(mx,dp[1][i][x]); } for(int i=0;i<64;i++) for(int j=0;j<64;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<64;i++) for(int j=0;j<64;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:71:13: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[100005]' [-Wformat=]
   71 |     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:70:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
miners.cpp:71:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |     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...