제출 #1149896

#제출 시각아이디문제언어결과실행 시간메모리
1149896modwwe드문 곤충 (IOI22_insects)C++20
100 / 100
15 ms448 KiB
//#include "gap.h"
//#include "mushrooms.h"
#include "insects.h"
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
//#define int   long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task2 "ftree"
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l,int r)
{
    return uniform_int_distribution<int>(l,r)(rd);
}
void phongbeo();
const int inf = 1e16;
const ll mod2 = 1e9+7;
const ll base=67;
int  n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int  i, s10, s12,k1,k2,k3,s11,lim,w,l,r ;
int kk;
int t;
int el = 19;/*
main()
{
    if(fopen(task2".inp","r"))
    {
        fin(task2);
        fou(task2);
    }
    if(fopen(task".inp","r"))
    {
        fin(task);
        fou(task);
    }
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    /// cin>>s1;
//int t;cin>>t; while(t--)
    phongbeo();
    // checktime
}
int c[1001];
int a[1001];
int d[1001];
void move_outside(int x)
{
    c[a[d[x]]]--;
    if(c[a[d[x]]]==0&&s2==a[d[x]])s2=a[d[x]]-1;
    a[d[x]]--;
    c[a[d[x]]]++;
}
void move_inside(int x)
{
    dem2++;
    c[a[d[x]]]--;
    a[d[x]]++;
    c[a[d[x]]]++;
    if(a[d[x]]>s2)s2=a[d[x]];
}
int press_button()
{
    return s2;
}*/
int lower[2001];
int haha[2001];
vector<int> rollback,v;
int min_cardinality(int N)
{
    n=N;
    for(int i=0; i<n; i++)
    {
        move_inside(i);
        if(press_button()==2)
            move_outside(i),v.pb(i);
        else
        {
            dem++;
            dem3++;
            lower[i]=1;
            rollback.pb(i);
        }
    }
    if(dem==1)return n;
    l=2;
    r=n/dem;
    while(l<=r)
    {
        int mid=l+r>>1;
                if(r-l>5) mid++;
        for(int i=0; i<n; i++)
            if(lower[i]>mid)
            {
                lower[i]=0;
                dem3--;
                move_outside(i);
            }
            bool de=0;
        for(int i=0; i<n; i++)
            if(lower[i]==0)
            {
                move_inside(i);
                if(press_button()==mid+1)
                { de=1;
                    move_outside(i);
                }
                else
                {
                    dem3++;
                    lower[i]=mid;
                    /// pos i<=mid
                }
            }
            if(!de) return mid;
        if(dem3!=dem*mid)
        {
            r=mid-1;
            for(int i=0; i<n; i++)if(lower[i]==0)lower[i]=-1;
        }
        else l=mid+1;
    }
    return l-1;
}/*
void phongbeo()
{
    for(int i=0; i<500; i++)
        d[i]=i/17;
    for(int i=500; i<1000; i++)
        d[i]=i/17;
    s3=min_cardinality(1000);
    cout<<s3<<" "<<dem2;
}*/

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

insects.cpp:28:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+16' to '2147483647' [-Woverflow]
   28 | const int inf = 1e16;
      |                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...