제출 #159656

#제출 시각아이디문제언어결과실행 시간메모리
159656GioChkhaidzeSnake Escaping (JOI18_snake_escaping)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define F first #define S second using namespace std; int n,q,C[1148576],M[20],dp[1794323],vs; pair < int , int > v[1794323]; main () { ios::sync_with_stdio(false); cin.tie(false); cin>>n>>q; M[0]=1; for (int i=1; i<=n; i++) M[i]=M[i-1]*3; for (int i=0; i<(1<<n); i++) { char c; cin>>c; C[i]=c-'0'; int x=0; for (int j=0; j<n; j++) if (i&(1<<j)) x+=M[j]; dp[x]+=C[i]; } for (int i=0; i<M[n]; i++) { int x=i,rs=0; for (int j=n-1; j>=0; j--) if (x-2*M[j]>=0) x-=2*M[j],rs++; else if (x-M[j]>=0) x-=M[j]; v[++vs].F=rs; v[vs].S=i; } sort(v+1,v+vs+1); for (int i=1; i<=vs; i++) { int x=v[i].S; for (int j=n-1; j>=0; j--) { if (x-2*M[j]>=0) { x-=2*M[j]; if (dp[v[i].S]<(dp[v[i].S-2*M[j]]+dp[v[i].S-M[j]])) dp[v[i].S]=(dp[v[i].S-2*M[j]]+dp[v[i].S-M[j]]); } else if (x-M[j]>=0) x-=M[j]; } } for (int i=1; i<=q; i++) { string s; int x=0; cin>>s; for (int j=0; j<s.size(); j++) { if (s[s.size()-j-1]=='?') x+=2*M[j]; else if (s[s.size()-j-1]=='1') x+=M[j]; } cout<<dp[x]<<endl; } }

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

snake_escaping.cpp:9:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () { 
       ^
snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:11:15: error: no matching function for call to 'std::basic_istream<char>::tie(bool)'
  cin.tie(false);
               ^
In file included from /usr/include/c++/7/ios:44:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from snake_escaping.cpp:1:
/usr/include/c++/7/bits/basic_ios.h:295:7: note: candidate: std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie() const [with _CharT = char; _Traits = std::char_traits<char>]
       tie() const
       ^~~
/usr/include/c++/7/bits/basic_ios.h:295:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/7/bits/basic_ios.h:307:7: note: candidate: std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie(std::basic_ostream<_CharT, _Traits>*) [with _CharT = char; _Traits = std::char_traits<char>]
       tie(basic_ostream<_CharT, _Traits>* __tiestr)
       ^~~
/usr/include/c++/7/bits/basic_ios.h:307:7: note:   no known conversion for argument 1 from 'bool' to 'std::basic_ostream<char>*'
snake_escaping.cpp:60:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j=0; j<s.size(); j++) {
                 ~^~~~~~~~~