Submission #318349

# Submission time Handle Problem Language Result Execution time Memory
318349 2020-11-01T11:30:13 Z neki ICC (CEOI16_icc) C++14
0 / 100
4 ms 500 KB
#include <bits/stdc++.h>
#include "icc.h"
 
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll int
#define loop(i, a, b) for(ll i=a;i<b;i++)
#define pool(i, a, b) for(ll i=a-1;i>=b;i--)
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 200100
#define pa pair<ll, ll>
#define ld long double
vc<vc<ll>> dsu;
 
ll que(ll sa, ll sb, vc<ll> a, vc<ll> b){
    ll qa[sa], qb[sb];
    loop(i, 0, sa) qa[i]=a[i];
    loop(i, 0, sb) qb[i]=b[i];
 
    return query(sa, sb, qa, qb);
}
void run(int n){
    loop(i, 1, n+1) dsu.ps(vc<ll> {i});
    
    loop(cnt, 0, n-1){
        vc<pa> ints={make_pair(0, dsu.size())};
        vc<ll> a[2];
        do{
            a[0].clear(), a[1].clear();
            vc<pa> ne;
            fore(v, ints){
                if(v.se-v.fi>1)ne.ps(make_pair(v.fi, (v.fi+v.se)/2)), ne.ps(make_pair((v.fi+v.se)/2, v.se));
                else ne.ps(v);
            }
            ints=ne;
            bool br=0;
            fore(v, ints){
                loop(j, v.fi, v.se) a[br].insert(a[br].end(), all(dsu[j]));
                br=!br;
            }
        }while(!que(a[0].size(), a[1].size(), a[0], a[1]));
        
        
        while(a[0].size()>1){
            vc<ll> b[2];
            loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
            if(que(a[1].size(), b[0].size(), a[1], b[0])) a[0]=b[0];
            else a[0]=b[1];
        }
        swap(a[0], a[1]);
        while(a[0].size()>1){
            vc<ll> b[2];
            loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
            if(que(a[1].size(), b[0].size(), a[1], b[0])) a[0]=b[0];
            else a[0]=b[1];
        }
        
        
        ll aa=a[0][0], ab=a[1][0];
        ll da, db;
        loop(j, 0, dsu.size()){
            fore(v, dsu[j]) if(v==aa)da=j;
            fore(v, dsu[j]) if(v==ab)db=j;
        }
        vc<ll> save=dsu[db];dsu.erase(dsu.begin()+db);
        dsu[ab].insert(dsu[ab].end(), all(save));
        
        setRoad(aa, ab);
    }
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:13:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 | #define loop(i, a, b) for(ll i=a;i<b;i++)
......
   57 |             loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
      |                  ~~~~~~~~~~~~~~~~~ 
icc.cpp:57:13: note: in expansion of macro 'loop'
   57 |             loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
      |             ^~~~
icc.cpp:57:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
      |                                       ~^~~~~~~~~~~~~~
icc.cpp:13:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 | #define loop(i, a, b) for(ll i=a;i<b;i++)
......
   64 |             loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
      |                  ~~~~~~~~~~~~~~~~~ 
icc.cpp:64:13: note: in expansion of macro 'loop'
   64 |             loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
      |             ^~~~
icc.cpp:64:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |             loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
      |                                       ~^~~~~~~~~~~~~~
icc.cpp:13:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 | #define loop(i, a, b) for(ll i=a;i<b;i++)
......
   72 |         loop(j, 0, dsu.size()){
      |              ~~~~~~~~~~~~~~~~      
icc.cpp:72:9: note: in expansion of macro 'loop'
   72 |         loop(j, 0, dsu.size()){
      |         ^~~~
icc.cpp:71:12: warning: variable 'da' set but not used [-Wunused-but-set-variable]
   71 |         ll da, db;
      |            ^~
icc.cpp:76:27: warning: 'db' may be used uninitialized in this function [-Wmaybe-uninitialized]
   76 |         vc<ll> save=dsu[db];dsu.erase(dsu.begin()+db);
      |                           ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 500 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 492 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 492 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 492 KB Wrong road!
2 Halted 0 ms 0 KB -