답안 #982796

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982796 2024-05-14T18:11:21 Z vjudge1 게임 (APIO22_game) C++17
2 / 100
4000 ms 344 KB
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int K;
int N;
vector<int> mini;
vector<int> maxi;
vector<vector<int>> teapuntan;
vector<vector<int>> apuntas;
void init(int n, int k) {
  N=n;
  K=k;
  mini.resize( n, 1e9);
  maxi.resize(n, -1);
  teapuntan.resize(n);
  apuntas.resize(n);
} 

int add_teleporter(int u, int v) {
  if(u<K && v<K){
    if(u>=v) return 1;
    return 0;
  }
   if(u<K){
      
      queue<int> q;
      q.push(v);
      while(!q.empty()){
        int x=q.front();
        q.pop();
        if(maxi[x]>u) continue;
        maxi[x]=u;
        if(maxi[x]>=mini[x]) return 1;
        for(int y: apuntas[x]){
          q.push(y);
        }

      }

   }
   else if(v<K){
      queue<int> q;
      q.push(u);
      while(!q.empty()){
        int x=q.front();
        q.pop();
        if(mini[x]<v) continue;
        mini[x]=v;
        if(maxi[x]>=mini[x]) return 1;
        for(int y:teapuntan[x]){
          q.push(y);
        }
      }
   }
   else{
    apuntas[u].pb(v);
    teapuntan[v].pb(u);
    queue<int> q;
    q.push(v);
    vector<bool> visited1 (N, false);
    while(!q.empty()){
      int x=q.front();
      q.pop();
      if(visited1[x]) continue;
      visited1[x]=1;
      if(maxi[x]>maxi[u]) continue;
      maxi[x]=maxi[u];
      if(maxi[x]>=mini[x]) return 1;
        for(int y: apuntas[x]){
          if(visited1[y]) continue;
          q.push(y);
        }

    }
    vector<bool> visited2 (N, 0);
    q.push(u);
     while(!q.empty()){
        int x=q.front();
        q.pop();
        if(visited2[x]) continue;
        visited2[x]=1;
        if(mini[x]<mini[v]) continue;
        mini[x]=mini[v];
        if(maxi[x]>=mini[x]) return 1;
        for(int y:teapuntan[x]){
          if(visited2[y]) continue;
          q.push(y);
        }
      }
   }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Execution timed out 4032 ms 344 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Execution timed out 4032 ms 344 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Execution timed out 4032 ms 344 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Execution timed out 4032 ms 344 KB Time limit exceeded
14 Halted 0 ms 0 KB -