Skip to content

Commit

Permalink
[docs] ChaNyeok1225 효율적인 해킹 제출 코드 및 채점 결과 2025-02-02T222841
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaNyeok1225 committed Feb 2, 2025
1 parent 8c25a71 commit 7f6c1d7
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# [Silver I] 효율적인 해킹 - 1325

[문제 링크](https://www.acmicpc.net/problem/1325)

### 성능 요약

메모리: 15732 KB, 시간: 128 ms

### 제출 일자

2025년 2월 2일 22:21:09

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <algorithm>
using namespace std;

int N, M;
vector<int> conn[10001];
bitset<10001> vis[10001];

int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

cin >> N >> M;

int a, b;
for (int i = 0; i < M; i++) {
cin >> a >> b;
conn[b].push_back(a);
}

queue<int> q;
int maxCount = 0;

for (int i = 1; i <= N; i++) {
q.push(i);
vis[i].set(i);

while (!q.empty()) {
int cur = q.front();
q.pop();

for (int next : conn[cur]) {
if (vis[i][next]) continue;
if (next < i)
vis[i] |= vis[next];
else {
q.push(next);
vis[i].set(next);
}
}
}
maxCount = max(maxCount, (int)vis[i].count());
}
vector<int> v;
for (int i = 1; i <= N; i++) {
int cnt = vis[i].count();
if (cnt == maxCount)
v.push_back(i);
}

for (int res : v) {
cout << res << " ";
}

}

0 comments on commit 7f6c1d7

Please sign in to comment.