답안 #605433

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
605433 2022-07-25T17:33:30 Z chirathnirodha CEOI16_icc (CEOI16_icc) C++17
100 / 100
137 ms 624 KB
#include "icc.h"
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define I insert
using namespace std;
int n;
int uni[101];
vector<int> v[101];
void solve(vector<int> vc){
    set<int> s;s.I(-1);s.I(vc.size()-1);
    vector<int> a,b;
    while(true){
        vector<int> v3;
        a.clear();b.clear();
        auto itr=s.begin();
        while(true){ 
            int l=*itr;l++;
            itr++;if(itr==s.end())break;
            int r=*itr;
            int m=(l+r)/2;
            v3.PB(m);
            for(int i=l;i<=m;i++){
                for(int j=0;j<v[vc[i]].size();j++)a.PB(v[vc[i]][j]);
            }
            for(int i=m+1;i<=r;i++){
                for(int j=0;j<v[vc[i]].size();j++)b.PB(v[vc[i]][j]);
            }
        }
        int arr1[a.size()],arr2[b.size()];
        for(int i=0;i<a.size();i++)arr1[i]=a[i];
        for(int i=0;i<b.size();i++)arr2[i]=b[i];
        bool bl=query(a.size(),b.size(),arr1,arr2);
        if(bl)break;
        for(int i=0;i<v3.size();i++)s.I(v3[i]);
    }
    while(true){
        if(a.size()==1 && b.size()==1)break;
        vector<int> v1,v2,v3;
        if(a.size()<b.size()){
            vector<int> c;
            for(int i=0;i<a.size();i++)c.PB(a[i]);
            a.clear();
            for(int i=0;i<b.size();i++)a.PB(b[i]);
            b.clear();
            for(int i=0;i<c.size();i++)b.PB(c[i]);
        }
        int m=(0+a.size()-1)/2;
        for(int i=0;i<=m;i++)v1.PB(a[i]);
        for(int i=0;i<b.size();i++)v2.PB(b[i]);
        int arr1[v1.size()],arr2[v2.size()];
        for(int i=0;i<v1.size();i++)arr1[i]=v1[i];
        for(int i=0;i<v2.size();i++)arr2[i]=v2[i];
        bool bl=query(v1.size(),v2.size(),arr1,arr2);
 
        if(bl)for(int i=0;i<=m;i++)v3.PB(a[i]);
        else for(int i=m+1;i<a.size();i++)v3.PB(a[i]);
            
        a.clear();
        for(int i=0;i<v3.size();i++)a.PB(v3[i]);
    }
    setRoad(a[0],b[0]);
	int prunib=uni[b[0]];
    for(int i=1;i<=n;i++){
        if(uni[i]==prunib){
            uni[i]=uni[a[0]];
            v[uni[a[0]]].PB(i);
        }
    }
    v[prunib].clear();
}
void run(int N){
    n=N;
    for(int i=1;i<=n;i++){
        uni[i]=i;
        v[i].PB(i);
    }
    for(int i=0;i<n-1;i++){
        vector<int> remu;
        for(int j=1;j<=n;j++)if(v[j].size()>0)remu.PB(j);
        solve(remu);
    }
}

Compilation message

icc.cpp: In function 'void solve(std::vector<int>)':
icc.cpp:26:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |                 for(int j=0;j<v[vc[i]].size();j++)a.PB(v[vc[i]][j]);
      |                             ~^~~~~~~~~~~~~~~~
icc.cpp:29:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |                 for(int j=0;j<v[vc[i]].size();j++)b.PB(v[vc[i]][j]);
      |                             ~^~~~~~~~~~~~~~~~
icc.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int i=0;i<a.size();i++)arr1[i]=a[i];
      |                     ~^~~~~~~~~
icc.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i=0;i<b.size();i++)arr2[i]=b[i];
      |                     ~^~~~~~~~~
icc.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int i=0;i<v3.size();i++)s.I(v3[i]);
      |                     ~^~~~~~~~~~
icc.cpp:44:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             for(int i=0;i<a.size();i++)c.PB(a[i]);
      |                         ~^~~~~~~~~
icc.cpp:46:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             for(int i=0;i<b.size();i++)a.PB(b[i]);
      |                         ~^~~~~~~~~
icc.cpp:48:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             for(int i=0;i<c.size();i++)b.PB(c[i]);
      |                         ~^~~~~~~~~
icc.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for(int i=0;i<b.size();i++)v2.PB(b[i]);
      |                     ~^~~~~~~~~
icc.cpp:54:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int i=0;i<v1.size();i++)arr1[i]=v1[i];
      |                     ~^~~~~~~~~~
icc.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int i=0;i<v2.size();i++)arr2[i]=v2[i];
      |                     ~^~~~~~~~~~
icc.cpp:59:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         else for(int i=m+1;i<a.size();i++)v3.PB(a[i]);
      |                            ~^~~~~~~~~
icc.cpp:62:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int i=0;i<v3.size();i++)a.PB(v3[i]);
      |                     ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 468 KB Ok! 95 queries used.
2 Correct 6 ms 496 KB Ok! 96 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 468 KB Ok! 550 queries used.
2 Correct 38 ms 488 KB Ok! 635 queries used.
3 Correct 36 ms 484 KB Ok! 611 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 500 KB Ok! 1436 queries used.
2 Correct 118 ms 500 KB Ok! 1580 queries used.
3 Correct 108 ms 624 KB Ok! 1532 queries used.
4 Correct 130 ms 492 KB Ok! 1478 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 492 KB Ok! 1510 queries used.
2 Correct 110 ms 500 KB Ok! 1517 queries used.
3 Correct 105 ms 504 KB Ok! 1512 queries used.
4 Correct 117 ms 528 KB Ok! 1494 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 504 KB Ok! 1504 queries used.
2 Correct 100 ms 504 KB Ok! 1490 queries used.
3 Correct 109 ms 512 KB Ok! 1541 queries used.
4 Correct 137 ms 496 KB Ok! 1558 queries used.
5 Correct 107 ms 500 KB Ok! 1469 queries used.
6 Correct 120 ms 508 KB Ok! 1528 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 105 ms 488 KB Ok! 1512 queries used.
2 Correct 101 ms 468 KB Ok! 1488 queries used.