Submission #350911

# Submission time Handle Problem Language Result Execution time Memory
350911 2021-01-19T09:49:48 Z Hossein29 Spiral (BOI16_spiral) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
const int maxn = 5e3+10;
const int maxm = 2e2+10;
const int inf = 1e9+1;
 
int n,m,w,h;
int tree[maxn][3]; // x , y , r
int vis[maxm][2]; // e , r
int p[maxn],sz[maxn],l[maxn],r[maxn],t[maxn],b[maxn],block[4][4];
vector<int>G[maxm];
 
int get_parent(int v){
    if(p[v] == v)
        return v;
    return p[v] = get_parent(p[v]);
}
 
void make_union(int v,int u, int r1){
    int a1 = get_parent(v);
    int b1 = get_parent(u);
    if(a1 == b1) return;
    if((min(abs(r[a1] - l[b1]),abs(r[b1] - l[a1]))) < 2*r1){
        if(min(abs(t[b1] - b[a1]),abs(b[b1] - t[a1])) < 2*r1){
            if(sz[a1] < sz[b1])
                swap(a1,b1);
            p[b1] = a1;
            sz[a1] += sz[b1];
            l[a1] = min(l[a1],l[b1]);
            r[a1] = max(r[a1],r[b1]);
            t[a1] = max(t[a1],t[b1]);
            b[a1] = min(b[a1],b[b1]);
        }
    }
    if(l[a1] == 0 && t[a1] == h) block[1][2] = true;
    if(l[a1] == 0 && r[a1] == w) block[1][3] = true;
    if(l[a1] == 0 && b[a1] == 0) block[1][4] = true;
    if(t[a1] == h && r[a1] == w) block[2][3] = true;
    if(t[a1] == h && b[a1] == 0) block[2][4] = true;
    if(r[a1] == w && b[a1] == 0) block[3][4] = true;
}
 
int32_t main(){
    ios:: sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ////////////////////////////////////////////////
    cin >> n >> m >> w >> h;
    for(int i = 1;i<=n;i++){
        cin >> tree[i][0] >> tree[i][1] >> tree[i][2];
    }
    for(int i = 0;i<m;i++){
        cin >> vis[i][0] >> vis[i][1];
        for(int j = 1;j<=n;j++){
            p[j] = j;
            sz[j] = 1;
            l[j] = max(0,(tree[j][0]-tree[j][2] < 2*vis[i][1] ? 0 : tree[j][0]-tree[j][2]));
            r[j] = min(w,(tree[j][0]+tree[j][2] + 2*vis[i][1] <= w ? tree[j][0]+tree[j][2] : w));
            t[j] = min(h,(tree[j][1]+tree[j][2] + 2*vis[i][1] <= h ? tree[j][0]+tree[j][2] : h));
            b[j] = max(0,(tree[j][1]-tree[j][2] - 2*vis[i][1] < 0 ? 0 : tree[j][1]-tree[j][2]));
            int a = j;
            if(l[a] == 0 && t[a] == h) block[1][2] = true;
            if(l[a] == 0 && r[a] == w) block[1][3] = true;
            if(l[a] == 0 && b[a] == 0) block[1][4] = true;
            if(t[a] == h && r[a] == w) block[2][3] = true;
            if(t[a] == h && b[a] == 0) block[2][4] = true;
            if(r[a] == w && b[a] == 0) block[3][4] = true;
        }
        for(int j = 0;j<6;j++){
            for(int k = 0;k<6;k++){
                block[i][j] = false;
            }
        }
        for(int j = 2;j<=n;j++){
            make_union(j,j-1,vis[i][0]);
        }
        if(vis[i][0] == 1){
            G[i].push_back(1);
            if(block[1][4] == true) continue;
            if(block[1][3] == false && block[1][2] == false) G[i].push_back(4);
            if(block[2][4] == false && block[3][4] == false) G[i].push_back(2);
            if(block[1][3] == false && block[2][4] == false && block[2][3] == false) G[i].push_back(3);
        }
        else if(vis[i][1] == 2){
            G[i].push_back(2);
            if(block[3][4] == true) continue;
            if(block[1][4] == false && block[2][4] == false) G[i].push_back(1);
            if(block[2][3] == false && block[1][3] == false) G[i].push_back(3);
            if(block[1][3] == false && block[2][4] == false && block[1][2] == false) G[i].push_back(4);
        }
        else if(vis[i][2] == 3){
            G[i].push_back(3);
            if(block[2][3] == true) continue;
            if(block[3][4] == false && block[1][3] == false) G[i].push_back(2);
            if(block[2][4] == false && block[1][2] == false) G[i].push_back(4);
            if(block[1][4] == false && block[2][4] == false && block[1][3] == false) G[i].push_back(1);
        }
        else{
            G[i].push_back(4);
            if(block[1][2] == true) continue;
            if(block[1][4] == false && block[1][3] == false) G[i].push_back(1);
            if(block[1][3] == false && block[2][4] == false && block[3][4] == false) G[i].push_back(2);
            if(block[2][3] == false && block[2][4] == false) G[i].push_back(3);
        }
    }
    for(int i = 0;i<m;i++){
        sort(G[i].begin(),G[i].end());
        for(int b : G[i])
            cout << b;
        cout << "\n";
    }
    return 0;
}

Compilation message

spiral.cpp: In function 'int32_t main()':
spiral.cpp:57:91: error: no matching function for call to 'max(int, long long int)'
   57 |             l[j] = max(0,(tree[j][0]-tree[j][2] < 2*vis[i][1] ? 0 : tree[j][0]-tree[j][2]));
      |                                                                                           ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from spiral.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:
spiral.cpp:57:91: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   57 |             l[j] = max(0,(tree[j][0]-tree[j][2] < 2*vis[i][1] ? 0 : tree[j][0]-tree[j][2]));
      |                                                                                           ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from spiral.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:
spiral.cpp:57:91: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   57 |             l[j] = max(0,(tree[j][0]-tree[j][2] < 2*vis[i][1] ? 0 : tree[j][0]-tree[j][2]));
      |                                                                                           ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from spiral.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:
spiral.cpp:57:91: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |             l[j] = max(0,(tree[j][0]-tree[j][2] < 2*vis[i][1] ? 0 : tree[j][0]-tree[j][2]));
      |                                                                                           ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from spiral.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:
spiral.cpp:57:91: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |             l[j] = max(0,(tree[j][0]-tree[j][2] < 2*vis[i][1] ? 0 : tree[j][0]-tree[j][2]));
      |                                                                                           ^
spiral.cpp:60:95: error: no matching function for call to 'max(int, long long int)'
   60 |             b[j] = max(0,(tree[j][1]-tree[j][2] - 2*vis[i][1] < 0 ? 0 : tree[j][1]-tree[j][2]));
      |                                                                                               ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from spiral.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:
spiral.cpp:60:95: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   60 |             b[j] = max(0,(tree[j][1]-tree[j][2] - 2*vis[i][1] < 0 ? 0 : tree[j][1]-tree[j][2]));
      |                                                                                               ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from spiral.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:
spiral.cpp:60:95: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   60 |             b[j] = max(0,(tree[j][1]-tree[j][2] - 2*vis[i][1] < 0 ? 0 : tree[j][1]-tree[j][2]));
      |                                                                                               ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from spiral.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:
spiral.cpp:60:95: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   60 |             b[j] = max(0,(tree[j][1]-tree[j][2] - 2*vis[i][1] < 0 ? 0 : tree[j][1]-tree[j][2]));
      |                                                                                               ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from spiral.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:
spiral.cpp:60:95: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   60 |             b[j] = max(0,(tree[j][1]-tree[j][2] - 2*vis[i][1] < 0 ? 0 : tree[j][1]-tree[j][2]));
      |                                                                                               ^