# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
421912 |
2021-06-09T13:39:55 Z |
반딧불(#7622) |
Collapse (JOI18_collapse) |
C++17 |
|
29 ms |
6328 KB |
#include "collapse.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Query{
int x, idx;
Query(){}
Query(int x, int idx): x(x), idx(idx){}
};
int n, k, q;
vector<Query> query[5002];
vector<int> link[5002];
int cut;
int ans[5002];
bool visited[5002];
void dfs(int x){
visited[x] = 1;
for(auto y: link[x]){
if(!visited[y]) continue;
if((x <= cut) ^ (y <= cut)) continue;
dfs(y);
}
}
vector<int> simulateCollapse(int N, vector<int> T, vector<int> X, vector<int> Y, vector<int> W, vector<int> P){
n = N, k = (int)T.size(), q = (int)W.size();
for(int i=0; i<q; i++){
query[W[i]-1].push_back(Query(P[i], i));
}
for(int i=0; i<k; i++){
if(T[i] == 0) link[X[i]].push_back(Y[i]), link[Y[i]].push_back(X[i]);
else{
link[X[i]].erase(find(link[X[i]].begin(), link[X[i]].end(), Y[i]));
link[Y[i]].erase(find(link[Y[i]].begin(), link[Y[i]].end(), X[i]));
}
for(Query qr: query[i]){
cut = qr.x;
fill(visited, visited+n, 0);
for(int i=0; i<n; i++){
if(!visited[i]){
ans[qr.idx]++;
dfs(i);
}
}
}
}
return vector<int> (ans, ans+q);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
29 ms |
6328 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
6256 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |