QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#34655 | #4251. Game | jli505# | 0 | 0ms | 5788kb | C++20 | 1.8kb | 2022-06-12 03:54:34 | 2024-05-23 13:10:20 |
Judging History
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;
}
詳細信息
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%