QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#863837 | #8117. Mostovi | Unforgettablepl | 0 | 13ms | 4096kb | C++20 | 1.3kb | 2025-01-19 23:41:09 | 2025-01-19 23:41:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int modulo = 1e9+7;
int32_t main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n,m;
cin >> n >> m;
vector<vector<int>> adj(n+1);
vector<pair<int,int>> edges(m);
for(int i=0;i<m;i++){
int a,b;
cin >> a >> b;
edges[i]={a,b};
adj[a].emplace_back(b);
adj[b].emplace_back(a);
}
vector isArt(n+1,vector(n+1,false));
for(int i=1;i<=n;i++){
vector<int> visited(n+1);
vector<int> child(n+1);
function<int(int,int,int)> dfs = [&](int x,int p,int depth){
visited[x]=depth;
int DP = 0;
bool isLeaf = true;
for(int&y:adj[x])if(y!=p){
if(visited[y]){
if(y!=i and visited[y]<depth)DP++;
else if(visited[y]>depth)DP--;
continue;
}
auto t = dfs(y,x,depth+1);
DP+=t;
isLeaf=false;
if(t==0){isArt[i][x]=true;}
child[x]++;
}
if(DP==0 and !isLeaf)isArt[i][x]=true;
return DP;
};
visited[i]=1;
assert(dfs(adj[i].front(),i,2)==0);
if(child[adj[i].front()]==1)isArt[i][adj[i].front()]=false;
bool works = true;
for(int&x:adj[i])if(!visited[x])works=false;
if(!works){
for(int j=1;j<=n;j++)isArt[i][j]=true;
}
}
int ans = 0;
for(int i=0;i<m;i++){
if(isArt[edges[i].first][edges[i].second])ans++;
}
cout << ans << '\n';
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3712kb
input:
98 139 65 67 11 10 16 18 13 14 37 39 69 67 7 6 38 41 40 38 22 28 98 94 50 49 73 72 10 12 38 37 75 72 47 43 81 83 66 65 76 72 94 97 76 73 66 64 2 5 91 92 74 73 81 78 33 29 27 23 93 96 31 35 53 55 36 35 7 5 87 90 46 43 34 35 12 13 73 75 39 38 87 91 20 19 30 31 56 50 2 1 1 4 43 42 24 23 76 75 1 3 72 71...
output:
110
result:
wrong answer 1st lines differ - expected: '108', found: '110'
Subtask #2:
score: 0
Wrong Answer
Test #43:
score: 0
Wrong Answer
time: 13ms
memory: 4096kb
input:
994 1419 470 469 910 911 428 434 622 623 574 570 661 665 437 438 857 858 863 862 637 633 222 219 796 794 294 295 182 183 234 237 279 280 361 364 1 2 96 92 199 203 735 736 968 967 936 934 680 681 414 418 784 785 508 510 589 594 584 586 225 228 88 91 971 969 827 829 301 302 662 664 344 350 917 913 3 6...
output:
1100
result:
wrong answer 1st lines differ - expected: '1076', found: '1100'
Subtask #3:
score: 0
Wrong Answer
Test #95:
score: 0
Wrong Answer
time: 13ms
memory: 4096kb
input:
994 1419 240 241 162 161 330 335 575 576 216 215 385 379 230 231 951 948 677 674 223 222 932 938 743 748 241 244 141 146 249 246 624 630 771 777 95 92 19 16 178 179 246 247 457 456 902 898 988 987 677 673 463 465 448 445 778 779 65 70 813 815 160 161 273 274 778 777 153 150 634 637 101 103 989 988 4...
output:
1074
result:
wrong answer 1st lines differ - expected: '1044', found: '1074'
Subtask #4:
score: 0
Wrong Answer
Test #154:
score: 12
Accepted
time: 0ms
memory: 3712kb
input:
21 38 2 7 8 9 14 12 7 8 17 16 16 20 18 20 6 4 20 15 1 6 15 16 11 13 17 18 10 11 15 17 13 9 2 1 15 14 4 1 18 19 13 14 10 8 3 1 15 21 14 11 2 6 19 20 12 11 5 7 2 5 2 3 21 17 8 12 11 8 4 7 14 10 21 18 5 1
output:
19
result:
ok single line: '19'
Test #155:
score: 12
Accepted
time: 1ms
memory: 3712kb
input:
21 38 7 5 20 18 6 3 8 9 16 17 3 5 5 6 18 19 17 19 10 11 17 15 4 2 4 3 1 4 3 2 2 6 15 21 11 14 16 21 9 10 1 7 8 14 6 4 13 10 9 11 8 12 9 14 16 15 14 13 8 7 21 18 13 9 21 20 17 21 18 15 15 14 1 2 13 11
output:
15
result:
ok single line: '15'
Test #156:
score: 12
Accepted
time: 0ms
memory: 3712kb
input:
21 38 21 18 21 19 10 11 2 1 10 8 16 15 10 12 14 8 3 6 17 20 2 3 1 3 9 13 7 2 1 6 5 1 16 18 20 16 11 8 21 16 11 12 6 7 15 21 12 14 8 7 16 17 10 14 16 19 6 2 8 12 15 14 3 4 15 18 9 8 1 7 17 21 4 7 8 13
output:
22
result:
ok single line: '22'
Test #157:
score: 12
Accepted
time: 1ms
memory: 3584kb
input:
21 38 16 21 6 2 16 19 6 1 20 19 11 8 10 11 2 7 5 1 5 6 10 13 20 17 10 14 17 18 1 2 7 8 15 20 9 12 17 21 8 10 10 9 21 20 14 15 14 13 8 9 9 11 19 17 3 1 10 12 7 1 6 4 18 20 6 7 15 16 4 1 5 7 17 15 11 13
output:
22
result:
ok single line: '22'
Test #158:
score: 12
Accepted
time: 0ms
memory: 3584kb
input:
21 38 5 7 8 10 12 8 8 11 21 18 2 7 7 3 1 4 17 15 13 10 8 14 3 6 4 3 9 14 16 15 18 20 2 3 6 7 16 17 15 14 11 14 18 15 5 6 16 20 20 21 12 9 18 16 21 15 8 7 2 1 19 17 9 10 18 17 2 6 5 2 8 9 10 12 13 8
output:
21
result:
ok single line: '21'
Test #159:
score: 0
Wrong Answer
time: 1ms
memory: 3712kb
input:
21 38 17 20 15 21 10 13 5 7 9 8 5 4 7 8 5 6 10 12 7 2 1 7 16 17 14 10 20 15 17 18 15 14 12 8 9 14 18 21 21 16 20 18 11 9 4 3 3 1 1 2 5 3 11 10 2 3 10 8 11 8 14 8 4 6 19 21 12 11 1 4 16 19 15 16 15 18
output:
21
result:
wrong answer 1st lines differ - expected: '20', found: '21'
Subtask #5:
score: 0
Time Limit Exceeded
Test #216:
score: 0
Time Limit Exceeded
input:
99995 142849 3388 3385 1883 1884 60752 60750 24094 24093 97084 97083 81408 81404 79388 79387 90741 90739 74918 74921 7354 7355 64236 64234 98928 98927 69618 69621 34595 34597 14050 14055 76055 76056 63593 63592 17507 17503 87218 87216 83931 83930 25805 25807 21744 21743 71708 71709 92053 92052 8830 ...