Submission #39562

# Submission time Handle Problem Language Result Execution time Memory
39562 2018-01-16T14:10:23 Z igzi ICC (CEOI16_icc) C++14
0 / 100
0 ms 2084 KB
#include <bits/stdc++.h>
#include "icc.h"
#define maxN 101

using namespace std;
vector <int> v[maxN];
vector <int> x;
int N;

int Query(vector<int> &a, vector<int> &b) {
  int tmp[2][maxN];
  for (int i = 0; i < a.size(); ++i) tmp[0][i] = a[i];
  for (int i = 0; i < b.size(); ++i) tmp[1][i] = b[i];
  return query(a.size(), b.size(), tmp[0], tmp[1]);
}
void zameni(int m,int d){
    int i;
    for(i=0;i<m;i++){
        int r=i/d;
        if(r%2) swap(x[i],x[i+m]);
    }
}
pair <int,int> resi(vector <int> &a,vector <int> &b){
    pair <int,int> ans;
    ans=make_pair(-1,-1);
    int i;
    vector <int> s;
    int A,B;
    A=a.size();
    B=b.size();
    int l=0,d=A,m;
    while(d!=l){
        m=(l+d)/2;
        for(i=l;i<m;i++){
            s.push_back(a[i]);
        }
        if(Query(b,s)) d=m;
        else l=m+1;
        s.clear();
    }
    ans.first=a[l];
    l=0,d=B;
    while(d!=l){
        m=(l+d)/2;
        for(i=l;i<m;i++){
            s.push_back(b[i]);
        }
        if(Query(a,s)) d=m;
        else l=m+1;
        s.clear();
    }
    ans.second=b[l];
    return ans;
}
void spoj(int a,int b){
    int i;
    if(a>b) swap(a,b);
    for(i=0;i<v[b].size();i++){
        v[a].push_back(v[b][i]);
    }
    v[b].clear();
}

void run(int n){
    N=n;
    int i,A=0,B=0,s;
    vector <int> a,b;
    for(i=1;i<=N;i++){
        v[i].push_back(i);
    }
    while(n>1){
        s=n & -n;
        if(s=n) s/=2;
        for(i=1;i<=N;i++){
            if(!v[i].empty()) x.push_back(i);
        }
        for(i=x.size();i<2*s;i++){
            x.push_back(-1);
        }
        for(i=0;i<s;i++){
            if(x[i]>=1 && x[i]<=N) a.push_back(x[i]);
        }
        for(i=s;i<x.size();i++){
            if(x[i]>=1 && x[i]<=N) b.push_back(x[i]);
        }
        int m=s,d=m/2;
        while(d>0 && !Query(a,b)){
            zameni(m,d);
            a.clear(); b.clear();
            for(i=0;i<s;i++){
            if(x[i]>=1 && x[i]<=N) a.push_back(x[i]);
        }
        for(i=s;i<x.size();i++){
            if(x[i]>=1 && x[i]<=N) b.push_back(x[i]);
        }
        d/=2;
        }
        pair <int,int> r;
        r=make_pair(1,1);
        r=resi(a,b);
        setRoad(r.first,r.second);
        spoj(r.first,r.second);
        n--;
    }
}

Compilation message

icc.cpp: In function 'int Query(std::vector<int>&, std::vector<int>&)':
icc.cpp:12:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < a.size(); ++i) tmp[0][i] = a[i];
                     ^
icc.cpp:13:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < b.size(); ++i) tmp[1][i] = b[i];
                     ^
icc.cpp: In function 'void spoj(int, int)':
icc.cpp:58:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<v[b].size();i++){
              ^
icc.cpp: In function 'void run(int)':
icc.cpp:73:15: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
         if(s=n) s/=2;
               ^
icc.cpp:83:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=s;i<x.size();i++){
                  ^
icc.cpp:93:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=s;i<x.size();i++){
                  ^
icc.cpp:66:11: warning: unused variable 'A' [-Wunused-variable]
     int i,A=0,B=0,s;
           ^
icc.cpp:66:15: warning: unused variable 'B' [-Wunused-variable]
     int i,A=0,B=0,s;
               ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2084 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2080 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2080 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2080 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2080 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2084 KB Wrong road!
2 Halted 0 ms 0 KB -