Submission #731558

# Submission time Handle Problem Language Result Execution time Memory
731558 2023-04-27T14:33:00 Z ogibogi2004 Game (APIO22_game) C++17
2 / 100
6 ms 7352 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=3e5+6;
const int SQ=600;
int min_nxt[MAXN];
vector<int>gr[MAXN];
int n,k;
void init(int _n, int _k) {
    n=_n;k=_k;
    for(int i=0;i<n;++i)
    {
        min_nxt[i]=n+1;
    }
}
bool set_min(int u,int val)
{
    min_nxt[u]=val;
    if(u<k&&min_nxt[u]<=u)return 1;
    for(auto xd:gr[u])
    {
        if(min_nxt[xd]>val)
        {
            bool flag=set_min(xd,val);
            if(flag==1)return 1;
        }
    }
    return 0;
}
void add_edge(int v,int u)
{
    if(gr[u].size()>SQ||gr[u].size()==0)
    {
        gr[v].push_back(u);
    }
    for(auto xd:gr[u])gr[v].push_back(xd);
}
int add_teleporter(int u, int v) {
    add_edge(v,u);
    if(u<k&&v<k)
    {
        if(u>=v)return 1;
        else return 0;
    }
    if(v<k)
    {
        if(v>=min_nxt[u])
        {
            //add_edge(v,u);
            //gr[v].push_back(u);
            return 0;
        }
        bool flag=set_min(u,v);
        //gr[v].push_back(u);
        return flag;
    }
    else if(min_nxt[v]>=min_nxt[u])
    {
        //gr[v].push_back(u);
        return 0;
    }
    bool flag=set_min(u,min_nxt[v]);

    //gr[v].push_back(u);
    return flag;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7248 KB Output is correct
2 Correct 4 ms 7248 KB Output is correct
3 Correct 4 ms 7248 KB Output is correct
4 Correct 4 ms 7248 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 4 ms 7248 KB Output is correct
7 Correct 6 ms 7352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7248 KB Output is correct
2 Correct 4 ms 7248 KB Output is correct
3 Correct 4 ms 7248 KB Output is correct
4 Correct 4 ms 7248 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 4 ms 7248 KB Output is correct
7 Correct 6 ms 7352 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 6 ms 7248 KB Output is correct
11 Incorrect 4 ms 7248 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7248 KB Output is correct
2 Correct 4 ms 7248 KB Output is correct
3 Correct 4 ms 7248 KB Output is correct
4 Correct 4 ms 7248 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 4 ms 7248 KB Output is correct
7 Correct 6 ms 7352 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 6 ms 7248 KB Output is correct
11 Incorrect 4 ms 7248 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7248 KB Output is correct
2 Correct 4 ms 7248 KB Output is correct
3 Correct 4 ms 7248 KB Output is correct
4 Correct 4 ms 7248 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 4 ms 7248 KB Output is correct
7 Correct 6 ms 7352 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 6 ms 7248 KB Output is correct
11 Incorrect 4 ms 7248 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7248 KB Output is correct
2 Correct 4 ms 7248 KB Output is correct
3 Correct 4 ms 7248 KB Output is correct
4 Correct 4 ms 7248 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 4 ms 7248 KB Output is correct
7 Correct 6 ms 7352 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 6 ms 7248 KB Output is correct
11 Incorrect 4 ms 7248 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -