Submission #39553

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

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

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

Compilation message

icc.cpp: In function 'void zameni(int, int)':
icc.cpp:11:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<x.size()/2;i++){
              ^
icc.cpp: In function 'void spoj(int, int)':
icc.cpp:46: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:64:18: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
         for(i=0;i<n & -n;i++){
                  ^
icc.cpp:67:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=n & -n;i<x.size();i++){
                       ^
icc.cpp:74:22: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
             for(i=0;i<n & -n;i++){
                      ^
icc.cpp:77:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=n & -n;i<x.size();i++){
                       ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2044 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2044 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2044 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2044 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2044 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2044 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -