Submission #964507

# Submission time Handle Problem Language Result Execution time Memory
964507 2024-04-17T04:15:07 Z steveonalex Super Dango Maker (JOI22_dango3) C++17
100 / 100
547 ms 1060 KB
#include <bits/stdc++.h>
#include "dango3.h"
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define ALL(v) (v).begin(), (v).end()
#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
 
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return ((ull) rng()) % (r - l + 1) + l;}
 
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
 
ll LASTBIT(ll mask){return mask & (-mask);}
ll pop_cnt(ll mask){return __builtin_popcountll(mask);}
ll ctz(ll mask){return __builtin_ctzll(mask);}
ll clz(ll mask){return __builtin_clzll(mask);}
ll logOf(ll mask){return 63 - clz(mask);}
 
template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if (a > b){a = b; return true;}
        return false;
    }
template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if (a < b){a = b; return true;}
        return false;
    }
template <class T>
    void printArr(T& a, string separator = " ", string finish = "\n", ostream& out = cout){
        for(auto i: a) out << i << separator;
        out << finish;
    }
template <class T>
    void remove_dup(vector<T> &a){
        sort(ALL(a));
        a.resize(unique(ALL(a)) - a.begin());
    }

// namespace Grader{
//     int n, m;
//     vector<int> a;
//     vector<bool> touched;
//     bool valid;
//     int o_cnt = 0;

//     int Query(vector<int> S){
//         o_cnt++;
//         vector<int> cnt(n+1);
//         for(int i: S) cnt[a[i]]++;
//         return (*min_element(1 + ALL(cnt)));
//     }

//     void Answer(vector<int> S){
//         if (S.size() != n) valid = false;
//         for(int i: S) touched[i] = true;
//     }

    void DnC(int n, int m, int sz, vector<int> SS){
        if (sz == 1){
            Answer(SS);
            return;
        }

        vector<int> L, R;
        vector<bool> check(SS.size());
        for(int i = 0; i<SS.size(); ++i){
            check[i] = 1;
            vector<int> S;
            for(int j = 0; j < SS.size(); ++j) if (check[j] == 0) S.push_back(SS[j]);
            if (Query(S) >= sz / 2){
                check[i] = 1;
                R.push_back(SS[i]);
            }
            else{
                check[i] = 0;
                L.push_back(SS[i]);
            }
        }
        DnC(n, m, sz / 2, L);
        DnC(n, m, (sz + 1) / 2, R);
    }

    void Solve(int n, int m){
        vector<int> S;
        for(int i = 1; i<=n*m; ++i) S.push_back(i);
        
        DnC(n, m, m, S);
    }

//     pair<bool, int> solve(int _n, int _m){
//         n = _n, m = _m;
//         a.clear(); a.push_back(0);
//         touched = vector<bool>(n * m + 1);
//         valid = true;

//         for(int i = 1; i<=n; ++i) for(int j = 1; j<=m; ++j) a.push_back(i);
//         shuffle(1 + ALL(a), rng);

//         Solve(n, m);

//         return make_pair((*(min_element(1 + ALL(touched))) == 1) && valid, o_cnt);
//     }

// }

// int main(void){
//     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//     int n = 400, m = 25;
//     pair<bool, int> verdict = Grader::solve(n, m);
//     if (verdict.first) cout << "AC\n";
//     else cout << "WA\n";
//     cout << "Operation cnt: " << verdict.second << "\n";

//     return 0;
// }

Compilation message

dango3.cpp: In function 'void DnC(int, int, int, std::vector<int>)':
dango3.cpp:74:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |         for(int i = 0; i<SS.size(); ++i){
      |                        ~^~~~~~~~~~
dango3.cpp:77:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |             for(int j = 0; j < SS.size(); ++j) if (check[j] == 0) S.push_back(SS[j]);
      |                            ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 520 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Correct 6 ms 348 KB Output is correct
4 Correct 7 ms 352 KB Output is correct
5 Correct 6 ms 520 KB Output is correct
6 Correct 6 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 120 ms 876 KB Output is correct
2 Correct 120 ms 604 KB Output is correct
3 Correct 133 ms 648 KB Output is correct
4 Correct 145 ms 648 KB Output is correct
5 Correct 117 ms 604 KB Output is correct
6 Correct 143 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 487 ms 1060 KB Output is correct
2 Correct 465 ms 808 KB Output is correct
3 Correct 540 ms 796 KB Output is correct
4 Correct 547 ms 1016 KB Output is correct
5 Correct 481 ms 748 KB Output is correct
6 Correct 483 ms 804 KB Output is correct