# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
362238 | knightron0 | Paint By Numbers (IOI16_paint) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
#define clr(a, x) memset(a, x, sizeof(a))
#define dbg(x) cout<<"("<<#x<<"): "<<x<<endl;
#define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define all(v) v.begin(), v.end()
#define lcm(a, b) (a * b)/__gcd(a, b)
#define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl;
#define endl '\n'
#define float long double
const int MOD = 1e9 + 7;
const int INF = 2e15;
const int MAXN = 1e5 + 5;
bool check(int idx, vector<int> c, bool which, string s){
// which = 0, if checking empty
// which = 1, if checking filled
int n = s.length();
int k= c.size();
if(which){
int tot = 0;
for(int i= 0;i<k;i++) tot += c[i];
bool valid = false;
int curr = 0;
for(int i= 0;i<k;i++){
for(int x = -1;x<=c[i];x++){
int z= x+1;
int y = c[i]-z;
if(idx-z >= 0 && idx +y < n){
int right = (n-(idx+y)-1);
int left = max(idx-z-1, 0LL);
int num = k-i;
if(left >= (curr + max(0LL, i-1)) && right >= ((tot-curr-c[i])+(max(0LL,num-1)))){
valid = true;
break;
}
}
}
if(valid){
break;
}
curr += c[i];
}
return valid;
} else {
int tot = 0;
int left = idx;
int right = n-idx-1;
for(int i= 0;i<k;i++) tot += c[i];
int curr = 0;
bool valid = false;
for(int i= 0;i<k;i++){
int num = k-i;
if(left >= (curr + max(0LL, i-1)) && right >= (tot-curr+(max(0LL,num-1)))){
valid = true;
break;
}
curr+= c[i];
}
if(left >= (curr + max(0LL, k-1)) && right >= (tot-curr)){
valid = true;
}
return valid;
}
}
string solve_puzzle(string s, vector<int> c){
int n = s.length();
string res = "";
for(int i= 0;i<n;i++){
bool empty = check(i, c, 0, s);
bool fill = check(i, c, 1, s);
if(empty && fill){
res += "?";
} else {
if(empty){
res += "_";
} else {
res += "X";
}
}
}
return res;
}
// signed main() {
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// #ifdef LOCAL
// freopen("input.txt", "r", stdin);
// #endif
// vector<int> nice;
// nice.pb(3);
// nice.pb(4);
// string s ="..........";
// cout<<solve_puzzle(s, nice)<<endl;
// return 0;
// }
Compilation message (stderr)
paint.cpp:17:17: warning: overflow in conversion from 'double' to 'int' changes value from '2.0e+15' to '2147483647' [-Woverflow] 17 | const int INF = 2e15; | ^~~~ paint.cpp: In function 'bool check(int, std::vector<int>, bool, std::string)': paint.cpp:39:33: error: no matching function for call to 'max(int, long long int)' 39 | int left = max(idx-z-1, 0LL); | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 222 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:222:5: note: template argument deduction/substitution failed: paint.cpp:39:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 39 | int left = max(idx-z-1, 0LL); | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 268 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:268:5: note: template argument deduction/substitution failed: paint.cpp:39:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 39 | int left = max(idx-z-1, 0LL); | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65, from paint.cpp:1: /usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3456 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: paint.cpp:39:33: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 39 | int left = max(idx-z-1, 0LL); | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65, from paint.cpp:1: /usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3462 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: paint.cpp:39:33: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 39 | int left = max(idx-z-1, 0LL); | ^ paint.cpp:41:37: error: no matching function for call to 'max(long long int, int)' 41 | if(left >= (curr + max(0LL, i-1)) && right >= ((tot-curr-c[i])+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 222 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:222:5: note: template argument deduction/substitution failed: paint.cpp:41:37: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 41 | if(left >= (curr + max(0LL, i-1)) && right >= ((tot-curr-c[i])+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 268 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:268:5: note: template argument deduction/substitution failed: paint.cpp:41:37: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 41 | if(left >= (curr + max(0LL, i-1)) && right >= ((tot-curr-c[i])+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65, from paint.cpp:1: /usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3456 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: paint.cpp:41:37: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | if(left >= (curr + max(0LL, i-1)) && right >= ((tot-curr-c[i])+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65, from paint.cpp:1: /usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3462 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: paint.cpp:41:37: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | if(left >= (curr + max(0LL, i-1)) && right >= ((tot-curr-c[i])+(max(0LL,num-1)))){ | ^ paint.cpp:41:83: error: no matching function for call to 'max(long long int, int)' 41 | if(left >= (curr + max(0LL, i-1)) && right >= ((tot-curr-c[i])+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 222 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:222:5: note: template argument deduction/substitution failed: paint.cpp:41:83: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 41 | if(left >= (curr + max(0LL, i-1)) && right >= ((tot-curr-c[i])+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 268 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:268:5: note: template argument deduction/substitution failed: paint.cpp:41:83: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 41 | if(left >= (curr + max(0LL, i-1)) && right >= ((tot-curr-c[i])+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65, from paint.cpp:1: /usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3456 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: paint.cpp:41:83: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | if(left >= (curr + max(0LL, i-1)) && right >= ((tot-curr-c[i])+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65, from paint.cpp:1: /usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3462 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: paint.cpp:41:83: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | if(left >= (curr + max(0LL, i-1)) && right >= ((tot-curr-c[i])+(max(0LL,num-1)))){ | ^ paint.cpp:62:35: error: no matching function for call to 'max(long long int, int)' 62 | if(left >= (curr + max(0LL, i-1)) && right >= (tot-curr+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 222 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:222:5: note: template argument deduction/substitution failed: paint.cpp:62:35: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 62 | if(left >= (curr + max(0LL, i-1)) && right >= (tot-curr+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 268 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:268:5: note: template argument deduction/substitution failed: paint.cpp:62:35: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 62 | if(left >= (curr + max(0LL, i-1)) && right >= (tot-curr+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65, from paint.cpp:1: /usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3456 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: paint.cpp:62:35: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 62 | if(left >= (curr + max(0LL, i-1)) && right >= (tot-curr+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65, from paint.cpp:1: /usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3462 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: paint.cpp:62:35: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 62 | if(left >= (curr + max(0LL, i-1)) && right >= (tot-curr+(max(0LL,num-1)))){ | ^ paint.cpp:62:74: error: no matching function for call to 'max(long long int, int)' 62 | if(left >= (curr + max(0LL, i-1)) && right >= (tot-curr+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 222 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:222:5: note: template argument deduction/substitution failed: paint.cpp:62:74: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 62 | if(left >= (curr + max(0LL, i-1)) && right >= (tot-curr+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 268 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:268:5: note: template argument deduction/substitution failed: paint.cpp:62:74: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 62 | if(left >= (curr + max(0LL, i-1)) && right >= (tot-curr+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65, from paint.cpp:1: /usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3456 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: paint.cpp:62:74: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 62 | if(left >= (curr + max(0LL, i-1)) && right >= (tot-curr+(max(0LL,num-1)))){ | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65, from paint.cpp:1: /usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3462 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: paint.cpp:62:74: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 62 | if(left >= (curr + max(0LL, i-1)) && right >= (tot-curr+(max(0LL,num-1)))){ | ^ paint.cpp:68:34: error: no matching function for call to 'max(long long int, int)' 68 | if(left >= (curr + max(0LL, k-1)) && right >= (tot-curr)){ | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 222 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:222:5: note: template argument deduction/substitution failed: paint.cpp:68:34: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 68 | if(left >= (curr + max(0LL, k-1)) && right >= (tot-curr)){ | ^ In file included from /usr/include/c++/9/bits/specfun.h:45, from /usr/include/c++/9/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41, from paint.cpp:1: /usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 268 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:268:5: note: template argument deduction/substitution failed: paint.cpp:68:34: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 68 | if(left >= (curr + max(0LL, k-1)) && right >= (tot-curr)){ | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,