QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#34657 | #4251. Game | jli505# | 0 | 1ms | 6124kb | C++20 | 1.8kb | 2022-06-12 03:58:24 | 2024-05-26 00:51:27 |
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];
int self_e[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){
if (u == v){
self_e[u]++;
}
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 || self_e[i]){
work = true;
}
}
return work;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 2
Accepted
time: 1ms
memory: 6124kb
input:
1 1 1 893123 893123 -1
output:
0
result:
ok interaction finished.
Test #2:
score: -2
Wrong Answer
time: 1ms
memory: 5844kb
input:
9 9 29 893122 893124 893121 893127 893120 893124 893123 893121 893122 893131 893125 893131 893121 893126 893123 893126 893126 893131 893123 893131 893123 893125 893123 893124 893127 893125 893120 893126 893123 893120 893121 893131 893123 893127 893122 893126 893122 893127 893127 893131 893122 893125...
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%