Submission #974594

# Submission time Handle Problem Language Result Execution time Memory
974594 2024-05-03T13:50:23 Z IUA_Hasin Game (APIO22_game) C++17
2 / 100
5 ms 10068 KB
#include "game.h"

#include <bits/stdc++.h>

#define endl                            "\n"
#define ll                              long long

using namespace std;

const ll N = 3e5+10;
ll NN, K;
std::vector<ll> graph[N];

ll vis[N];
ll vis2[N];

std::vector<ll> nodes;
std::vector<ll> dfs(ll source){
    if(vis[source]==0){
        vis[source] = 1;
        nodes.push_back(source);
        for(auto u : graph[source]){
            dfs(u);
        }
    } else {
        return nodes;
    }

    return nodes;
}


void init(int n, int k) {
  NN = n;
  K = k;
  for(int i=0; i<=k-2; i++){
    graph[i].push_back(i+1);
    // cout << i << " " << i+1 << endl;
  }
}


int add_teleporter(int u, int v) {
    // cout << u << " " << v << endl;
    // cout<<endl;
    graph[u].push_back(v);
    for(int i=0; i<NN; i++){
        vis[i] = 0;
    }
    nodes.clear();

    if(u>=K && v<K){
        vis2[u] = 1;
        // cout<<u<<endl;
    }

    if(u>=v && u<K){
      return 1;
    } else {
        std::vector<ll> v = dfs(0);

        // for(int i=0; i<v.size(); i++){
        //     cout << v[i] << " ";
        // }
        // cout<<endl;

        ll status = 0;
        for(int i=0; i<v.size(); i++){
            if(status==1){
                break;
            } else {
                ll a = v[i];
                if(vis2[a]==1){
                    status = 1;
                    break;
                }
            }
        }
        return status;
    }


}

Compilation message

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:68:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         for(int i=0; i<v.size(); i++){
      |                      ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 9816 KB Output is correct
2 Correct 3 ms 9816 KB Output is correct
3 Correct 5 ms 9816 KB Output is correct
4 Correct 2 ms 9816 KB Output is correct
5 Correct 5 ms 10068 KB Output is correct
6 Correct 4 ms 9816 KB Output is correct
7 Correct 5 ms 9816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 9816 KB Output is correct
2 Correct 3 ms 9816 KB Output is correct
3 Correct 5 ms 9816 KB Output is correct
4 Correct 2 ms 9816 KB Output is correct
5 Correct 5 ms 10068 KB Output is correct
6 Correct 4 ms 9816 KB Output is correct
7 Correct 5 ms 9816 KB Output is correct
8 Correct 3 ms 9812 KB Output is correct
9 Correct 2 ms 9816 KB Output is correct
10 Correct 2 ms 9816 KB Output is correct
11 Incorrect 4 ms 9816 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 9816 KB Output is correct
2 Correct 3 ms 9816 KB Output is correct
3 Correct 5 ms 9816 KB Output is correct
4 Correct 2 ms 9816 KB Output is correct
5 Correct 5 ms 10068 KB Output is correct
6 Correct 4 ms 9816 KB Output is correct
7 Correct 5 ms 9816 KB Output is correct
8 Correct 3 ms 9812 KB Output is correct
9 Correct 2 ms 9816 KB Output is correct
10 Correct 2 ms 9816 KB Output is correct
11 Incorrect 4 ms 9816 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 9816 KB Output is correct
2 Correct 3 ms 9816 KB Output is correct
3 Correct 5 ms 9816 KB Output is correct
4 Correct 2 ms 9816 KB Output is correct
5 Correct 5 ms 10068 KB Output is correct
6 Correct 4 ms 9816 KB Output is correct
7 Correct 5 ms 9816 KB Output is correct
8 Correct 3 ms 9812 KB Output is correct
9 Correct 2 ms 9816 KB Output is correct
10 Correct 2 ms 9816 KB Output is correct
11 Incorrect 4 ms 9816 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 9816 KB Output is correct
2 Correct 3 ms 9816 KB Output is correct
3 Correct 5 ms 9816 KB Output is correct
4 Correct 2 ms 9816 KB Output is correct
5 Correct 5 ms 10068 KB Output is correct
6 Correct 4 ms 9816 KB Output is correct
7 Correct 5 ms 9816 KB Output is correct
8 Correct 3 ms 9812 KB Output is correct
9 Correct 2 ms 9816 KB Output is correct
10 Correct 2 ms 9816 KB Output is correct
11 Incorrect 4 ms 9816 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -