제출 #1366294

#제출 시각아이디문제언어결과실행 시간메모리
1366294kokoxuyaGuessing Game (EGOI23_guessinggame)C++20
0 / 100
419 ms1228 KiB
//you cannot mark for urself
//everyone marks for some other guy:
//ambiguity: if everyone marks for one other guy, there needs to be 999998 markers
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define lsb(x) (x&(-x))
#define pii pair<int,int>
#define ss second
#define ff first
#define piii pair<int,pii>
#define debu(x) (cerr << #x  << " = "<< x << "\n")
#define debu2(x,y) (cerr << #x  << " = "<< x << " " << #y << " = " << y << "\n")
#define debu3(x,y,z) (cerr << #x  << " = "<< x << " " << #y << " = " << y << " " << #z << " = " << z<< "\n")
#define bitout(x,y) {\
    cerr << #x << " : ";\
    for (int justforbits = y; justforbits >=0; justforbits--)cout << (((1 << justforbits) & x)>=1);\
    cout << "\n";\
}
#define rangeout(j,rangestart,rangeend) {\
    cerr << "outputting " << #j<< ":\n";\
    for (int forrang = rangestart; forrang <= rangeend; forrang++)cerr << j[forrang] << " ";\
    cerr<<"\n";\
}
#define c1 {cerr << "Checkpoint 1! \n\n";cerr.flush();}
#define c2 {cerr << "Checkpoint 2! \n\n";cerr.flush();}
#define c3 {cerr << "Checkpoint 3! \n\n";cerr.flush();}
#define c4 {cerr << "Checkpoint 4! \n\n";cerr.flush();}
#define vi vector<int>
#define vpii vector<pii>
#define fr(i,x,y) for(int i=x;i<=y;i++)
int p,n;
//FAHHH IVE BEEN DOING grp=t1/segsz instead of grp=i/segsz im so genuinely fried what the heck

int ip(){int x;cin>>x;return x;}
void op(int x){cout<<x<<endl;cout.flush();}
void op2(int x, int y){cout<<x<<" "<<y<<endl;cout.flush();}
int segno,segsz;
int lastsz;


void Alice()
{
    //segment numbers 0 indexed, segment counts themselves are 1-indexed
    vector<int>cnt(segno,0),mn(segno,segsz-1);
    mn[segno-1]=lastsz-1;
    
    int k=segsz+segno-2;
    int secdeg=segsz;
    
    op(k);
    
    int t1,t2;
    for(int i=0;i<n-1;i++)
    {
        cin>>t1;
        int grp=t1/segsz;
        if(cnt[grp]==mn[grp]){t2=secdeg++;}
        else {cnt[grp]++;t2=cnt[grp];}
        op(t2);
    }
}

void Bob()
{
    int k=segsz+segno-2;
    
    vector<vi>ccnt(segno,vi(segsz,-1));
    vi lcnt(segno,-1);
    vector<int>mn(segno,segsz-1);
    mn[segno-1]=lastsz-1;
    
    
    vi ans;//c2;
    for(int i=0;i<n;i++)
    {
        int t1;cin>>t1;
        int grp=i/segsz;
        //debu3(i,t1,grp);
        
        if(t1>mn[grp]&&t1<=mn[0]){ans.pb(i);break;}
        else if(t1<=mn[grp])
        {//c2;
            debu2(i,ccnt[grp][t1]);
            if(ccnt[grp][t1]!=-1){ans.pb(i);ans.pb(ccnt[grp][t1]);break;}
            ccnt[grp][t1]=i;
        }
        else
        {//c3;
            if(lcnt[t1-segsz]!=-1){ans.pb(lcnt[t1-segsz]);ans.pb(i);break;}
            lcnt[t1-segsz]=i;
        }
    }
    
    //c1;
    if(ans[0]==0){ans.pb(1);}
    else{ans.pb(0);}
    
    op2(ans[0],ans[1]);
}

signed main()
{
    int t1,t2,t3,t4;
    mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>p>>n;
    segno=sqrt(n)+1;segsz=sqrt(n);
    //debu2(segno,segsz);
    lastsz=n-(segno-1)*segsz;
    if(p==1)
    {
        Alice();
    }
    else
    {
        Bob();
    }
    return 0;
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…