답안 #116478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116478 2019-06-12T14:25:56 Z JohnTitor CEOI16_icc (CEOI16_icc) C++11
90 / 100
138 ms 640 KB
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
#define __builtin_popcount __builtin_popcountll
using ll=long long; using ld=long double;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2;
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
#define taskname "ICC"
#ifndef Aria
#include "icc.h"
#else
    int query(int as, int bs, int a[], int b[]){

    }

#endif // Aria
int r[201];
vector <int> g[201];
int root(int u){
    if(r[u]<0) return u;
    return r[u]=root(r[u]);
}
void unite(int u, int v){
    u=root(u);
    v=root(v);
    if(u==v) return;
    if(r[u]>r[v]) swap(u, v);
    for(int x: g[v]) g[u].pb(x);
    r[u]+=r[v];
    r[v]=u;
}
int cnt=0;
int a[200];
int b[200];
bool ask(vector <int> left, vector <int> right){
    cnt++;
    if(left.empty()||right.empty()){
        while(true){
            int c;
            writeln(c);
        }
    }
    FFOR(i, 0, left.size()) a[i]=left[i];
    FFOR(i, 0, right.size()) b[i]=right[i];
    return query(left.size(), right.size(), a, b);
}
bool askcomp(vector <int> left, vector <int> right){
    vector <int> rl;
    vector <int> rr;
    for(int x: left) for(int y: g[x]) rl.pb(y);
    for(int x: right) for(int y: g[x]) rr.pb(y);
    return ask(rl, rr);
}
void run(int n){
    FOR(i, 1, n){
        r[i]=-1;
        g[i].pb(i);
    }
    FFOR(cnt, 1, n){
        vector <int> component;
        FOR(i, 1, n) if(i==root(i)) component.pb(i);
        vector <int> left, right;
        FFOR(b, 0, 10){
            left.clear();
            right.clear();
            FFOR(i, 0, component.size()) if(bit(i, b)) left.pb(component[i]); else right.pb(component[i]);
            if(left.empty()||right.empty()) continue;
            if(askcomp(left, right)) break;
        }
        vector <int> tl, tr;
        tl=left;
        tr=right;
        left.clear();
        right.clear();
        for(int x: tl) for(int y: g[x]) left.pb(y);
        for(int x: tr) for(int y: g[x]) right.pb(y);
        while(left.size()>1){
            tl.clear();
            FFOR(i, 0, left.size()/2) tl.pb(left[i]);
            if(ask(tl, right)) left=tl;
            else{
                tl.clear();
                FFOR(i, left.size()/2, left.size()) tl.pb(left[i]);
                left=tl;
            }
        }
        while(right.size()>1){
            tr.clear();
            FFOR(i, 0, right.size()/2) tr.pb(right[i]);
            if(ask(left, tr)) right=tr;
            else{
                tr.clear();
                FFOR(i, right.size()/2, right.size()) tr.pb(right[i]);
                right=tr;
            }
        }
        if(left.empty()||right.empty()) ask(left, right);
        unite(left[0], right[0]);
        setRoad(left[0], right[0]);
    }
}
//int main(){
//    #ifdef Aria
//        if(fopen(taskname".in", "r"))
//            freopen(taskname".in", "r", stdin);
//    #endif // Aria
//}

Compilation message

icc.cpp: In function 'bool ask(std::vector<int>, std::vector<int>)':
icc.cpp:4:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FFOR(i, j, k) for(int i=(j); i<(k); i++)
                                       ^
icc.cpp:54:5: note: in expansion of macro 'FFOR'
     FFOR(i, 0, left.size()) a[i]=left[i];
     ^~~~
icc.cpp:4:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FFOR(i, j, k) for(int i=(j); i<(k); i++)
                                       ^
icc.cpp:55:5: note: in expansion of macro 'FFOR'
     FFOR(i, 0, right.size()) b[i]=right[i];
     ^~~~
icc.cpp: In function 'void run(int)':
icc.cpp:4:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FFOR(i, j, k) for(int i=(j); i<(k); i++)
                                       ^
icc.cpp:77:13: note: in expansion of macro 'FFOR'
             FFOR(i, 0, component.size()) if(bit(i, b)) left.pb(component[i]); else right.pb(component[i]);
             ^~~~
icc.cpp:4:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FFOR(i, j, k) for(int i=(j); i<(k); i++)
                                       ^
icc.cpp:90:13: note: in expansion of macro 'FFOR'
             FFOR(i, 0, left.size()/2) tl.pb(left[i]);
             ^~~~
icc.cpp:4:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FFOR(i, j, k) for(int i=(j); i<(k); i++)
                                       ^
icc.cpp:94:17: note: in expansion of macro 'FFOR'
                 FFOR(i, left.size()/2, left.size()) tl.pb(left[i]);
                 ^~~~
icc.cpp:4:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FFOR(i, j, k) for(int i=(j); i<(k); i++)
                                       ^
icc.cpp:100:13: note: in expansion of macro 'FFOR'
             FFOR(i, 0, right.size()/2) tr.pb(right[i]);
             ^~~~
icc.cpp:4:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FFOR(i, j, k) for(int i=(j); i<(k); i++)
                                       ^
icc.cpp:104:17: note: in expansion of macro 'FFOR'
                 FFOR(i, right.size()/2, right.size()) tr.pb(right[i]);
                 ^~~~
icc.cpp: In function 'bool ask(std::vector<int>, std::vector<int>)':
icc.cpp:50:17: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
             int c;
                 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 512 KB Ok! 94 queries used.
2 Correct 7 ms 512 KB Ok! 103 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 512 KB Ok! 526 queries used.
2 Correct 41 ms 564 KB Ok! 687 queries used.
3 Correct 44 ms 632 KB Ok! 702 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 114 ms 576 KB Ok! 1500 queries used.
2 Correct 138 ms 512 KB Ok! 1704 queries used.
3 Correct 128 ms 632 KB Ok! 1669 queries used.
4 Correct 126 ms 632 KB Ok! 1561 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 604 KB Ok! 1636 queries used.
2 Correct 136 ms 632 KB Ok! 1608 queries used.
3 Correct 135 ms 512 KB Ok! 1704 queries used.
4 Correct 115 ms 512 KB Ok! 1572 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 124 ms 640 KB Ok! 1704 queries used.
2 Correct 120 ms 612 KB Ok! 1703 queries used.
3 Correct 127 ms 512 KB Ok! 1700 queries used.
4 Correct 124 ms 604 KB Ok! 1690 queries used.
5 Correct 115 ms 512 KB Ok! 1518 queries used.
6 Correct 116 ms 512 KB Ok! 1575 queries used.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 120 ms 512 KB Too many queries! 1703 out of 1625
2 Halted 0 ms 0 KB -