제출 #432372

#제출 시각아이디문제언어결과실행 시간메모리
432372juggernautMiners (IOI07_miners)C++17
0 / 100
2 ms332 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 cost[64]; int add(int x,int id){ x>>=2; x|=(id<<4); return cost[x]; } int main(){ 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); int x=0; int y=0; int ans=0; for(int i=0;i<n;i++){ char &ch=s[i]; int id; if(ch=='M')id=1; if(ch=='B')id=2; if(ch=='F')id=3; if(add(x,id)>add(y,id)){ x>>=2; x|=(id<<4); ans+=cost[x]; }else{ y>>=2; y|=(id<<4); ans+=cost[y]; } } printf("%d",ans); }

컴파일 시 표준 에러 (stderr) 메시지

miners.cpp: In function 'int main()':
miners.cpp:44:13: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[100005]' [-Wformat=]
   44 |     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:43:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
miners.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     scanf("%s",&s);
      |     ~~~~~^~~~~~~~~
miners.cpp:24:11: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |     x|=(id<<4);
      |        ~~~^~~~
miners.cpp:50:13: note: 'id' was declared here
   50 |         int id;
      |             ^~
#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...