QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#34655#4251. Gamejli505#0 0ms5788kbC++201.8kb2022-06-12 03:54:342024-05-23 13:10:20

Judging History

你现在查看的是最新测评结果

  • [2024-05-23 13:10:20]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:5788kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-12 03:54:34]
  • 提交

answer

#include <bits/stdc++.h>
#include "game.h"
using namespace std;

void fastIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

int N, M, K;


vector<int> adj[100100];
 
stack<int> S;
 
int cnt = 0;
int dfn[100100], low[100100];
bool in_stack[100100];
int time_in = 0;
int kingdom[100100];

void init(int n, int k){
    N = n;
    K = k;
    for (int i = 0; i < k-1; i++){
        adj[i].push_back(i+1);
    }
}

void dfs(int node){
    dfn[node] = ++time_in;
    low[node] = dfn[node];
    S.push(node);
    in_stack[node] = true;
    for (int nx : adj[node]){
        if (!dfn[nx]){
            dfs(nx);
            low[node] = min(low[node], low[nx]);
        } else if (in_stack[nx]){
            low[node] = min(low[node], dfn[nx]);
        }
    }
    if (low[node] == dfn[node]){
        ++cnt;
        while (S.top() != node){
            kingdom[S.top()] = cnt;
            in_stack[S.top()] = false;
            S.pop();
        }
        kingdom[S.top()] = cnt;
        in_stack[S.top()] = false;
        S.pop();
    }
}

int kcnt[100100];

int add_teleporter(int u, int v){
    adj[u].push_back(v);
    time_in = 0;
    cnt = 0;
    for (int i = 0; i < N; i++){
        dfn[i] = low[i] = in_stack[i] = kcnt[i] = kingdom[i] = 0;
    }
    while (!S.empty()){
        S.pop();
    }
    for (int i = 0; i < N; i++){
        if (!dfn[i]){
            dfs(i);
        }
    }
    /*for (int i = 0; i < N; i++){
        cout << kingdom[i] << " ";
    }
    cout << "\n";*/
    for (int i = 0; i < N; i++){
        kcnt[kingdom[i]]++;
    }
    bool work = false;
    for (int i = 0; i < K; i++){
        if (kcnt[kingdom[i]] > 1){
            work = true;
        }
    }
    return work;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 5788kb

input:

1 1
1
893123 893123
-1

output:

1

result:

wrong answer Wrong Answer [1]

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%