Submission #1346054

#TimeUsernameProblemLanguageResultExecution timeMemory
1346054Joon_YorigamiMagic Show (APIO24_show)C++20
5 / 100
2 ms1092 KiB
#include <vector>
#include <bits/stdc++.h>
#include "Alice.h"
using namespace std;
using ll=int;
// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().

std::vector<std::pair<int,int>> Alice(){
	// add your code here
	
	// change below into your code
    std::vector<std::pair<int,int>> ret;
    long long x = setN(5000);
    if(x<=5000)
    {
        for(int i=1;i<=5000;i++)
        {
            if(i==x)continue;
            ret.push_back({x,i});
        }
        return ret;
    }
    ll a,b;
    a=(x-5000)/4999+1;
    b=(x-5000)%4999+1;
    b+=(b>=a);
    for(int i=1;i<=1667;i++)
    {
        if(i==a || i==b || i==(a^b))
            continue;
        ret.push_back({i,a});
    }
    for(int i=1668;i<=3334;i++)
    {
        if(i==a || i==b || i==(a^b))
            continue;
        ret.push_back({i,b});
    }
    for(int i=3335;i<=5000;i++)
    {
        if(i==a || i==b || i==(a^b))
            continue;
        ret.push_back({i,a^b});
    }
    ret.push_back({a,b});
    ret.push_back({b,a^b});
    return ret;
}
#include <vector>
#include <bits/stdc++.h>
#include "Bob.h"
using namespace std;
using ll=int;
// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().

bool checkIfDumbCase(std::vector<std::pair<int,int>> &adj)
{
    vector<int> degree(5001,0);
    for(auto edge:adj) 
    {
        degree[edge.first]+=1;
        degree[edge.second]+=1;
    }
    int cnt=0;
    for(int i=1;i<=5000;i++)
        cnt+=degree[i]>1;
    return cnt==1;
}

long long Bob(std::vector<std::pair<int,int>> adj){
	// add your code here
    vector<int> degree(5001,0);
    for(auto edge:adj) 
    {
        degree[edge.first]+=1;
        degree[edge.second]+=1;
    }
	if(checkIfDumbCase(adj))
    {
        for(int i=1;i<=5000;i++)
            if(degree[i]>1)
                return i;
    }
    ll a=-1,b=-1,c=-1;
    vector<ll> candidateA(5001,0);
    vector<ll> candidateB(5001,0);
    vector<ll> candidateC(5001,0);
    int u,v;
    for(auto edge:adj)
    {
        u=edge.first;
        v=edge.second;
        if(1<=u && u<=1667)
            candidateA[v]+=1;
        if(1667<=u && u<=3334)
            candidateB[v]+=1;
        if(3335<=u && u<=5000)
            candidateC[v]+=1;
        swap(u,v);
        if(1<=u && u<=1667)
            candidateA[v]+=1;
        if(1667<=u && u<=3334)
            candidateB[v]+=1;
        if(3335<=u && u<=5000)
            candidateC[v]+=1;
    }
    for(int i=1;i<=5000;i++)
    {
        if(candidateA[i]>10)
            a=i;
    }
    for(int i=1;i<=5000;i++)
    {
        if(candidateB[i]>10)
            b=i;
    }
    for(int i=1;i<=5000;i++)
    {
        if(candidateC[i]>10)
            c=i;
    }
    if(a==-1)
        a=b^c;
    if(b==-1)
        b=a^c;
    ll ans=5000;
    ans+=(a-1)*4999;
    ans+=(b-(b>=a))-1;
    return ans; // change this into your code
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...