제출 #1315344

#제출 시각아이디문제언어결과실행 시간메모리
1315344muhammad-ahmadCONSUL (info1cup19_consul)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
// #include "grader.h"
// #include "A.cpp"

using namespace std;

static const int MIN_VALUE = 0, MAX_VALUE = (1e9) - 1;

static map<int,int> mp;
static int Q, N, a[5005];
static bool issol, answer;


void say_answer(int k)
{
    if(answer)
    {
        cout << "Multiple answers provided for the same testcase!\n";
        exit(0);
    }
    answer = 1;

    if(k == -1)
    {
        if(issol)
        {
            cout << "Wrong answer\n";
            exit(0);
        }
        else cout << "Correct! Number of queries: " << Q << '\n';
    }
    else
    {
        if(!issol || mp[k] <= N/3)
        {
            cout << "Wrong answer\n";
            exit(0);
        }
        else cout << "Correct! Number of queries: " << Q << '\n';
    }
}

int cnt(int k)
{
    ++Q;
    if(!(k>=MIN_VALUE && k<=MAX_VALUE))
    {
        cout << "Wrong query format\n";
        exit(0);
    }
    return mp[k];
}

int kth(int k)
{
    ++Q;
    if(!(k>=1 && k<=N))
    {
        cout << "Wrong query format\n";
        exit(0);
    }
    return a[k];
}

void solve(int N){
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int l = 1, r = N;
	int ans = -1;
	for (int q = 1; q <= 25; q++){
		int x = uniform_int_distribution<int>(l,r)(rng);
		int val = kth(x);
		int C = cnt(val);
		if (C > N / 3) ans = val;
	}
	say_answer(ans);
}

int main()
{
    int tests, i;
    cin >> tests;

    while(tests--)
    {
        cin >> N; mp.clear();
        Q = 0; issol = 0; answer = 0;

        for(i=1; i<=N; ++i) cin >> a[i], ++mp[a[i]];
        for(i=1; i<=N; ++i) issol |= (mp[a[i]] > N/3);
        solve(N);
    }

    return 0;
}

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

/usr/bin/ld: /tmp/ccWDZdJr.o: in function `kth(int)':
grader.cpp:(.text+0x0): multiple definition of `kth(int)'; /tmp/ccNc9Bfi.o:consul.cpp:(.text+0x650): first defined here
/usr/bin/ld: /tmp/ccWDZdJr.o: in function `cnt(int)':
grader.cpp:(.text+0xb0): multiple definition of `cnt(int)'; /tmp/ccNc9Bfi.o:consul.cpp:(.text+0x570): first defined here
/usr/bin/ld: /tmp/ccWDZdJr.o: in function `say_answer(int)':
grader.cpp:(.text+0x160): multiple definition of `say_answer(int)'; /tmp/ccNc9Bfi.o:consul.cpp:(.text+0x3b0): first defined here
/usr/bin/ld: /tmp/ccWDZdJr.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccNc9Bfi.o:consul.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status