Submission #1341756

#TimeUsernameProblemLanguageResultExecution timeMemory
1341756mysticmage45Art Class (IOI13_artclass)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "artclass.h"
using namespace std;

#define ll long long

const vector<pair<ll, ll>> bsf_direction = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
    srand(98485232);

    auto Cal_diff = [&](pair<ll, ll> a, pair<ll, ll> b){
        return abs(R[a.first][a.second] - R[b.first][b.second]) +
        abs(G[a.first][a.second] - G[b.first][b.second]) +
        abs(B[a.first][a.second] - B[b.first][b.second]);
    };
    
    auto find_avg_bfs = [&](ll MAX_diff, ll bsf_interation){
        vector<vector<ll>> bsf_check(H, vector<ll>(W, -1));

        ll sum_bsf = 0;
        for(ll i = 0; i < bsf_interation; i++){
            queue<pair<ll, ll>> bsf_q;
            pair<ll, ll> FirstPostion = {rand() % H, rand() % W};

            bsf_q.emplace(FirstPostion);
            bsf_check[FirstPostion.first][FirstPostion.second] = i;
            sum_bsf++;

            while(!bsf_q.empty()){
                pair<ll, ll> position = bsf_q.front();
                bsf_q.pop();

                for(pair<ll, ll> dir : bsf_direction){
                    pair<ll, ll> NextPosition = {position.first + dir.first, position.second + dir.second};

                    if(NextPosition.first < 0 || NextPosition.first >= H ||
                        NextPosition.second < 0 || NextPosition.second >= W){
                        break;
                    }
                    else if(bsf_check[NextPosition.first][NextPosition.second] == i){
                        break;
                    }
                    else if(Cal_diff(NextPosition, FirstPostion) > MAX_diff){
                        break;
                    }

                    bsf_q.emplace(NextPosition);
                    bsf_check[NextPosition.first][NextPosition.second] = i;
                    sum_bsf++;   
                }
            }
        }

        ll avg_bsf = sum_bsf/bsf_interation;

        return avg_bsf;
    };
    
    ll avg = find_avg_bfs(38, 50);

    if(avg < 6){
        return 3;
    }
    else if(avg < 50){
        return 2;
    }

    // cout << "avg_bsf = " << avg_bsf << endl; 

    /*if(avg < 50){
        ll sum_green = 0;
        for(ll i = 0; i < H; i++){
            for(ll j = 0; j < W; j++){
                sum_green += G[i][j] - max(R[i][j], B[i][j]);
            }
        }

        ll avg_green = sum_green/(H*W);

        cout << avg_green << endl;

        if(avg_green > 150){
            return 2;
        }
        else{
            return 3;
        }

    }*/

    //avg = find_avg_bfs(150, 100);

    // cout << "avg_bsf_2 = " << avg << endl;

    {
        ll max_diff = 0;
        for(ll i = 0; i < H-2; i++){
            for(ll j = 0; j < W-2; j++){
                max_diff = max(max_diff, Cal_diff({i, j}, {i+2, j+2}));
            }
        }

        if(max_diff > 500){
            return 1;
        }
        else{
            return 4;
        }
    }
    
    /*if(avg > 600){
        return 4;
    }
    else{
        return 1;
    }*/

    
}

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:100:31: error: no matching function for call to 'max(long long int&, int)'
  100 |                 max_diff = max(max_diff, Cal_diff({i, j}, {i+2, j+2}));
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from artclass.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
artclass.cpp:100:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  100 |                 max_diff = max(max_diff, Cal_diff({i, j}, {i+2, j+2}));
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
artclass.cpp:100:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  100 |                 max_diff = max(max_diff, Cal_diff({i, j}, {i+2, j+2}));
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
artclass.cpp:100:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  100 |                 max_diff = max(max_diff, Cal_diff({i, j}, {i+2, j+2}));
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
artclass.cpp:100:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  100 |                 max_diff = max(max_diff, Cal_diff({i, j}, {i+2, j+2}));
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~