제출 #32344

#제출 시각아이디문제언어결과실행 시간메모리
32344imaxblue게임판 (CEOI13_board)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define x first #define y second #define pii pair<int, int> #define p3i pair<pii, int> #define pll pair<ll, ll> #define p3l pair<pll, ll> #define lseg L, (L+R)/2, N*2+1 #define rseg (L+R)/2+1, R, N*2+2 #define ub upper_bound #define lb lower_bound #define pq priority_queue #define MN 1000000007 #define fox(k, x) for (int k=0; k<x; ++k) #define fox1(k, x) for (int k=1; k<=x; ++k) #define foxr(k, x) for (int k=x-1; k>=0; --k) #define fox1r(k, x) for (int k=x; k>0; --k) #define ms multiset #define flood(x) memset(x, 0x3f3f3f3f, sizeof x) #define drain(x) memset(x, 0, sizeof x) #define rng() (rand() >> 3)*rand() set<int> pre; string s, t; bool type; int p, x; void flip(int p){ if (pre.count(p)) pre.erase(p); else pre.insert(p); } string con(string S){ type=0; p=0; pre.clear(); fox(l, S.size()){ if (S[l]=='1' && type){ type=0; pre.insert(p); } if (S[l]=='2' && !type){ type=1; pre.insert(p); } if (S[l]=='1' || S[l]=='2') p++; if (S[l]=='U'){ --p; if (pre.count(p)){ type=!type; pre.erase(p); } } if (S[l]=='L'){ if (type){ flip(p-1); } else { x=*--pre.end(); flip(--x); } type=!type; } if (S[l]=='R'){ if (!type){ flip(p-1); } else { x=*--pre.end(); flip(--x); } type=!type; } } type=0; S=""; //cout << p << endl; fox(l, p){ if (pre.count(l)) type=!type; S+=char(type+'0'); } return S; } int main(){ cin.sync_with_stdio(0); cin.tie(0); cin >> s; s=con(s); cin >> t; t=con(t); //cout << s << ' ' << endl << t << endl; ll a=0, b=0, ans=(1LL << 60); fox(l, min(s.size(), t.size())){ a=a*2+s[l]-'0'; b=b*2+t[l]-'0'; if (abs(b-a)>200000) break; //cout << a << ' ' << b << endl; ans=min(ans, abs(a-b)+s.size()+t.size()-l*2-2); } cout << ans << endl; return 0; }

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

board.cpp: In function 'std::__cxx11::string con(std::__cxx11::string)':
board.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
                                  ^
board.cpp:37:5: note: in expansion of macro 'fox'
     fox(l, S.size()){
     ^
board.cpp: In function 'int main()':
board.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
                                  ^
board.cpp:91:5: note: in expansion of macro 'fox'
     fox(l, min(s.size(), t.size())){
     ^
board.cpp:96:54: error: no matching function for call to 'min(long long int&, long long unsigned int)'
         ans=min(ans, abs(a-b)+s.size()+t.size()-l*2-2);
                                                      ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from board.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
board.cpp:96:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
         ans=min(ans, abs(a-b)+s.size()+t.size()-l*2-2);
                                                      ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from board.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/5/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
board.cpp:96:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
         ans=min(ans, abs(a-b)+s.size()+t.size()-l*2-2);
                                                      ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from board.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3445:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^
/usr/include/c++/5/bits/stl_algo.h:3445:5: note:   template argument deduction/substitution failed:
board.cpp:96:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         ans=min(ans, abs(a-b)+s.size()+t.size()-l*2-2);
                                                      ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from board.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3451:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^
/usr/include/c++/5/bits/stl_algo.h:3451:5: note:   template argument deduction/substitution failed:
board.cpp:96:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         ans=min(ans, abs(a-b)+s.size()+t.size()-l*2-2);
                                                      ^