답안 #77289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
77289 2018-09-24T19:10:58 Z toreto_back 통행료 (IOI18_highway) C++14
0 / 100
180 ms 2304 KB
#include "highway.h"
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef double D;
const ll mod=1e9+7;
const ll inf=(1ll<<61);
const int MX=3e5+9;

void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
    int l=0,r=N-1,m=U.size(),n=N;
    int q=99;
    vector<int>w;
    for(int i=0;i<m;i++)w.push_back(0);
    ll c=ask(w);
    int len=c/A;
    while(r-l+1>2*len && r-l+1-len+1>q){
        int mid=(l+r)/2;
        for(int i=0;i<n;i++)w[i]=0;
        for(int i=l;i<mid;i++)w[i]=1;
        ll c1=ask(w);q--;
        if(c1==c){
            l=max(0,mid-len+1);
        }
        else r=min(mid+len-1,n-1);
    }
    int p=0,x=10;
    while(r-l+1-len+1>q){
//        cout<<r-l+1-len+1<<" "<<q<<endl;
//            cout<<l<<" "<<r<<endl;
        for(int i=0;i<n;i++)w[i]=0;
        if(p){
            int mid=(r-l+1)/x+l;
            for(int i=l;i<mid;i++)w[i]=1;
            ll c1=ask(w);q--;
            if(c1==c){
                l=mid+1;
            }
            else r=mid+len-1;
        }
        else{
        int mid=r-(r-l+1)/x;
            for(int i=r;i>mid;i--)w[i]=1;
            ll c1=ask(w);q--;
            if(c1==c){
                r=mid-1;
            }
            else l=mid-len+1;
        }
        p^=1;
        x+=10;
    }
    for(int i=l;i+len<=r;i++){
        for(int j=0;j<m;j++)w[j]=1;
        for(int j=i;j<len+i;j++)w[j]=0;
        ll c1=ask(w);
        if(c1==c){
            answer(i,i+len);
            break;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 248 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 504 KB Output is correct
2 Correct 33 ms 860 KB Output is correct
3 Correct 56 ms 1152 KB Output is correct
4 Incorrect 180 ms 2304 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 600 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 596 KB Output is incorrect: answered not exactly once.
2 Halted 0 ms 0 KB -