제출 #903614

#제출 시각아이디문제언어결과실행 시간메모리
903614JakobZorzThe Big Prize (IOI17_prize)C++17
90 / 100
35 ms2840 KiB
#include"prize.h"
#include<iostream>
#include<vector>
#include<set>
using namespace std;

bool dpt[200000];
pair<int,int>dp[200000];
int n;
bool found;

void query(int i){
    if(dpt[i])
        return;
    dpt[i]=true;
    auto res=ask(i);
    dp[i]={res[0],res[1]};
    if(res[0]+res[1]==0){
        found=true;
        return;
    }
    int c=i+1;
    while(c<n){
        if(dpt[c]){
            if(dp[c]==dp[i]){
                for(int j=i+1;j<c;j++){
                    dp[j]=dp[i];
                    dpt[j]=true;
                }
            }
            break;
        }
        c++;
    }
    
    c=i-1;
    while(c>=0){
        if(dpt[c]){
            if(dp[c]==dp[i]){
                for(int j=c+1;j<i;j++){
                    dp[j]=dp[i];
                    dpt[j]=true;
                }
            }
            break;
        }
        c--;
    }
}

void fo(int l,int r){
    if(l>=r)
        return;
    int m1=l+(r-l)/3;
    int m2=l+(r-l)*2/3;
    if(found)
        return;
    query(m1);
    query(m2);
    
    if(l<r-2){
        /*if(dp[m].first>dp[m].second){
            fo(l,m);
            fo(m,r);
        }else{
            fo(m,r);
            fo(l,m);
        }*/
        
        fo(l,m1);
        fo(m1,m2);
        fo(m2,r);
    }
}

int find_best(int N){
    n=N;
    fo(0,n);
    
    for(int i=0;i<n;i++)
        if(dpt[i]&&dp[i].first+dp[i].second==0)
            return i;
    
	return -1;
}

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'int find_best(int)':
prize.cpp:80:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   80 |     for(int i=0;i<n;i++)
      |     ^~~
prize.cpp:84:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   84 |  return -1;
      |  ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...