Submission #75062773


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
int n,m,cnt,a[300005];
vector<int> e[300005];
void dfs(int u){
	a[u]=1;
	for(int i=0;i<e[u].size();i++){
		int v=e[u][i];
		if(!a[v]) dfs(v);
	}
}
int main(){
	cin>>n>>m;
	for(int i=1,x,y;i<=m;i++) cin>>x>>y,e[x].push_back(y);
	dfs(1);
	for(int i=1;i<=n;i++) if(a[i]) cnt++;
	cout<<cnt;
} 

Submission Info

Submission Time
Task C - Straw Millionaire
User Rya_
Language C++23 (GCC 15.2.0)
Score 300
Code Size 351 Byte
Status AC
Exec Time 200 ms
Memory 30552 KiB

Compile Error

./Main.cpp: In function 'void dfs(int)':
./Main.cpp:7:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |         for(int i=0;i<e[u].size();i++){
      |                     ~^~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 22
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 03_killer_00.txt, 03_killer_01.txt, 03_killer_02.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 3516 KiB
00_sample_01.txt AC 2 ms 3544 KiB
00_sample_02.txt AC 2 ms 3592 KiB
01_handmade_00.txt AC 55 ms 5532 KiB
01_handmade_01.txt AC 55 ms 5548 KiB
01_handmade_02.txt AC 55 ms 5016 KiB
01_handmade_03.txt AC 78 ms 5928 KiB
01_handmade_04.txt AC 75 ms 5616 KiB
01_handmade_05.txt AC 200 ms 30532 KiB
01_handmade_06.txt AC 189 ms 30552 KiB
01_handmade_07.txt AC 140 ms 15496 KiB
01_handmade_08.txt AC 142 ms 15272 KiB
01_handmade_09.txt AC 51 ms 10072 KiB
02_random_00.txt AC 145 ms 17240 KiB
02_random_01.txt AC 96 ms 7244 KiB
02_random_02.txt AC 56 ms 4820 KiB
02_random_03.txt AC 113 ms 7568 KiB
02_random_04.txt AC 90 ms 5516 KiB
02_random_05.txt AC 90 ms 5616 KiB
03_killer_00.txt AC 121 ms 11312 KiB
03_killer_01.txt AC 99 ms 11296 KiB
03_killer_02.txt AC 133 ms 23900 KiB