Submission #972079

# Submission time Handle Problem Language Result Execution time Memory
972079 2024-04-30T03:52:49 Z steveonalex Chameleon's Love (JOI20_chameleon) C++17
4 / 100
14 ms 596 KB
#include <bits/stdc++.h>
#include "chameleon.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;
//     vector<int> Y, C, L;
//     vector<int> check;
//     int o_cnt, ans;

//     int Query(const vector<int> &p){
//         o_cnt++;
//         vector<bool> state(n * 2 + 1);
//         for(int i: p) state[i] = 1;
//         vector<bool> color(n*2+1);
//         for(int i: p){
//             if (state[L[i]]) color[C[L[i]]] = 1;
//             else color[C[i]] = 1;
//         }

//         int ans = 0;
//         for(int i = 1; i<=2*n; ++i) ans += color[i];
//         return ans;
//     }

//     void Answer(int x, int y){
//         cout << "! " << x << " " << y << "\n";
//         if (C[x] != C[y]) ans = false;
//         check[x]++; check[y]++;
//     }

    void Solve(int n){
        vector<int> S, T;
        for(int i = 1; i<=2*n; ++i){
            S.push_back(i);
            if (Query(S) == S.size()){

            }
            else {
                S.pop_back();
                T.push_back(i);
            }
        }
        for(int i: T){
            int l = 0, r = S.size() - 1;
            while(l < r){
                int mid = (l + r) >> 1;
                vector<int> vcl;
                for(int i = 0; i<=mid; ++i) vcl.push_back(S[i]);
                vcl.push_back(i);

                if (Query(vcl) != vcl.size()) r = mid;
                else l = mid + 1;
            }
            Answer(i, S[l]);
        }
    }

//     pair<bool, int> run_test(int _n){
//         n = _n;
//         Y.resize(n * 2 + 1); L = C = Y;
//         for(int i= 1; i<=2*n; ++i) cin >> Y[i];
//         for(int i= 1; i<=2*n; ++i) cin >> C[i];
//         for(int i= 1; i<=2*n; ++i) cin >> L[i];
//         o_cnt = 0; ans = 1;
//         check = vector<int>(2*n+1);

//         Solve(n);

//         if (*max_element(1+ALL(check)) != 1 || *min_element(1+ALL(check)) != 1) ans = false;
//         return {ans, o_cnt};
//     }
// }

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

//     int n; cin >> n;
//     pair<bool, int> verdict = Grader::run_test(n);
//     if (verdict.first) cout << "AC\n";
//     else cout << "WA\n";

//     cout << "Total operation count: " << verdict.second << "\n";

//     return 0;
// }

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:78:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |             if (Query(S) == S.size()){
      |                 ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp:94:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |                 if (Query(vcl) != vcl.size()) r = mid;
      |                     ~~~~~~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 14 ms 344 KB Output is correct
4 Correct 12 ms 464 KB Output is correct
5 Correct 12 ms 344 KB Output is correct
6 Correct 12 ms 344 KB Output is correct
7 Correct 12 ms 456 KB Output is correct
8 Correct 12 ms 596 KB Output is correct
9 Correct 12 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 14 ms 344 KB Output is correct
4 Correct 12 ms 464 KB Output is correct
5 Correct 12 ms 344 KB Output is correct
6 Correct 12 ms 344 KB Output is correct
7 Correct 12 ms 456 KB Output is correct
8 Correct 12 ms 596 KB Output is correct
9 Correct 12 ms 464 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Incorrect 0 ms 344 KB Wrong Answer [6]
12 Halted 0 ms 0 KB -