제출 #1363601

#제출 시각아이디문제언어결과실행 시간메모리
1363601biserailievaGuessing Game (EGOI23_guessinggame)C++20
0 / 100
364 ms856 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int P, N;
    cin>>P>>N;
    if(P==1)
    {
        cout<<(N+1)/2<<endl; 
        for(int i=0;i<N-1;i++)
        {
            int idx;
            cin>>idx; 
            if(i<(N+1)/2)
            {
                cout<<i+1<<endl;
            }
            else
            {
                cout<<i-(N+1)/2+1<<endl;
            }
        }
    }
    else
    {
        vector<int>A(N);
        unordered_map<int, int>freq, freq2;
        int i1=-1, i2=-1;
        for(int i=0;i<N;i++)
        {
            cin>>A[i];
        }
        for(int i=0;i<N;i++)
        {
            if (i < (N + 1) / 2)
            {
                if (freq.count(A[i]))
                {
                    i1 = freq[A[i]];
                    i2 = i;
                    break;
                }
                freq[A[i]] = i;
            }
            else
            {
                if (freq2.count(A[i]))
                {
                    i1 = freq2[A[i]];
                    i2 = i;
                    break;
                }
                freq2[A[i]] = i;
            }
        }
        if (i1 == -1)
        {
            cout << 0 << " " << 0 << endl;
        }
        else
        {
            cout << i1 << " " << i2 << endl;
        }
    }
    return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…