Submission #863699

# Submission time Handle Problem Language Result Execution time Memory
863699 2023-10-20T17:41:22 Z TahirAliyev ICC (CEOI16_icc) C++17
100 / 100
88 ms 648 KB
#include "icc.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pii pair<int, int>
#define oo 1e9

vector<vector<int>> comps;

int n;

void f(vector<int> a, vector<int>& b){
    while(b.size() != 1){
        vector<int> tmp;
        for(int i = 0; i <= (b.size() - 1) / 2; i++){
            tmp.push_back(b[i]);
        }
        if(query(a.size(), tmp.size(), a.data(), tmp.data())){
            b = tmp;
        }
        else{
            for(int i = 0; i < tmp.size(); i++){
                b.erase(b.begin());
            }
        }
    }
}

vector<int> conv(vector<int> c){
    vector<int> res;
    for(int i : c){
        for(int a : comps[i]){
            res.push_back(a);
        }
    }
    return res;
}

void run(int N){
    n = N;
    for(int i = 1; i <= n; i++){
        comps.push_back({i});
    }
    for(int z = 1; z < n; z++){
        random_shuffle(comps.begin(), comps.end());
        vector<int> a, b;
        for(int j = 0; j < 8; j++){
            for(int i = 0; i < comps.size(); i++){
                if((1 << j) & i) a.push_back(i);
                else b.push_back(i);
            }
            if(query(conv(a).size(), conv(b).size(), conv(a).data(), conv(b).data())) break;
            a.clear(), b.clear();
        }
        vector<int> v1 = conv(a), v2 = conv(b);
        f(v1, v2);
        f(v2, v1);
        int c1, c2;
        for(int i = 0; i < comps.size(); i++){
            for(int j : comps[i]){
                if(v1[0] == j) c1 = i;
                if(v2[0] == j) c2 = i;
            }
        }
        vector<int> v;
        v.swap(comps[c1]);
        for(int j : comps[c2]){
            v.push_back(j);
        }
        if(c1 < c2) swap(c1, c2);
        comps.erase(comps.begin() + c1);
        comps.erase(comps.begin() + c2);
        comps.push_back(v);
        setRoad(v1[0], v2[0]);
    }
}

Compilation message

icc.cpp: In function 'void f(std::vector<int>, std::vector<int>&)':
icc.cpp:17:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for(int i = 0; i <= (b.size() - 1) / 2; i++){
      |                        ~~^~~~~~~~~~~~~~~~~~~~~
icc.cpp:24:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             for(int i = 0; i < tmp.size(); i++){
      |                            ~~^~~~~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:50:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |             for(int i = 0; i < comps.size(); i++){
      |                            ~~^~~~~~~~~~~~~~
icc.cpp:61:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for(int i = 0; i < comps.size(); i++){
      |                        ~~^~~~~~~~~~~~~~
icc.cpp:72:9: warning: 'c2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   72 |         if(c1 < c2) swap(c1, c2);
      |         ^~
icc.cpp:68:24: warning: 'c1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   68 |         v.swap(comps[c1]);
      |                        ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 604 KB Ok! 103 queries used.
2 Correct 4 ms 604 KB Ok! 102 queries used.
# Verdict Execution time Memory Grader output
1 Correct 26 ms 604 KB Ok! 532 queries used.
2 Correct 27 ms 604 KB Ok! 655 queries used.
3 Correct 26 ms 604 KB Ok! 644 queries used.
# Verdict Execution time Memory Grader output
1 Correct 71 ms 624 KB Ok! 1372 queries used.
2 Correct 88 ms 604 KB Ok! 1621 queries used.
3 Correct 83 ms 604 KB Ok! 1617 queries used.
4 Correct 78 ms 600 KB Ok! 1507 queries used.
# Verdict Execution time Memory Grader output
1 Correct 77 ms 648 KB Ok! 1482 queries used.
2 Correct 76 ms 632 KB Ok! 1467 queries used.
3 Correct 83 ms 624 KB Ok! 1600 queries used.
4 Correct 80 ms 632 KB Ok! 1473 queries used.
# Verdict Execution time Memory Grader output
1 Correct 84 ms 604 KB Ok! 1599 queries used.
2 Correct 83 ms 600 KB Ok! 1583 queries used.
3 Correct 84 ms 600 KB Ok! 1609 queries used.
4 Correct 85 ms 604 KB Ok! 1591 queries used.
5 Correct 76 ms 600 KB Ok! 1460 queries used.
6 Correct 87 ms 636 KB Ok! 1538 queries used.
# Verdict Execution time Memory Grader output
1 Correct 84 ms 640 KB Ok! 1598 queries used.
2 Correct 85 ms 604 KB Ok! 1611 queries used.