제출 #821024

#제출 시각아이디문제언어결과실행 시간메모리
821024ZHIRDILBILDIZ커다란 상품 (IOI17_prize)C++14
20 / 100
3094 ms5252 KiB
#include<bits/stdc++.h>
#include "prize.h"
using namespace std ;
const int N = 2e5 ;
//vector<int> ask(int ind)
//{
//    vector<int> v(2) ;
//    cout << "? " << ind << '\n' ;
//    cin >> v[0] >> v[1] ;
//    return v ;
//}
vector<int> all[N + 1] ;
int find_best(int n)
{
//    bool flag = 0 ;
    int l = -1, r = n, cnt = 0 ;
//    while(l + 1 < r)
//    {
//        int mid = (l + r) / 2 ;
//        cnt++ ;
//        vector<int> v = ask(mid) ;
//        all[mid] = v ;
//        if(v[0] && v[1])
//        {
//            flag = 1 ;
//            break ;
//        }
//        if(!v[0] && !v[1])
//            return mid ;
//        else
//        {
//            if(v[0])
//                r = mid ;
//            else
//                l = mid ;
//        }
//    }
//    if(!flag)
//        return l ;
    int ind = 0 ;
    while(ind < n)
    {
        if(ind == n - 1)
            return ind ;
        vector<int> abu = all[ind] ;
        if(!abu.size())
        {
            cnt++ ;
            abu = ask(ind) ;
            all[ind] = abu ;
        }
        if(cnt == 10000)
        {
            while(true)
            {
            }
        }
        if(!abu[0] && !abu[1])
            return ind ;
        int l = ind - 1, r = n ;
        while(l + 1 < r)
        {
            int mid = (l + r) / 2 ;
            vector<int> now = all[mid] ;
            if(!now.size())
            {
                cnt++ ;
                now = ask(mid) ;
                all[mid] = now ;
            }
            if(cnt == 10000)
            {
                while(true)
                {
                }
            }
            if(!now[0] && !now[1])
                return mid ;
            else
            {
                if(now[0] == abu[0] && now[1] == abu[1])
                    l = mid ;
                else
                    r = mid ;
            }
        }
        ind = l + 1 ;
    }
}
//signed main()
//{
//    int n ;
//    cin >> n ;
//    cout<<find_best(n) ;
//    return 0 ;
//}

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:16:9: warning: unused variable 'l' [-Wunused-variable]
   16 |     int l = -1, r = n, cnt = 0 ;
      |         ^
prize.cpp:16:17: warning: unused variable 'r' [-Wunused-variable]
   16 |     int l = -1, r = n, cnt = 0 ;
      |                 ^
prize.cpp:89:1: warning: control reaches end of non-void function [-Wreturn-type]
   89 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...