Submission #39712018


Source Code Expand

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define IOS ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


typedef tree<int,null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update>order_set;
typedef pair<int,int>pr;
#define all(i)     i.begin() , i.end()
#define ft     first
#define sn     second
#define pb push_back


#define en "\n"
#define dbg cout<<"rony\n";

#define MAXN 2010
#define inf 1e8
const int mod = 998244353;

int n,m;
vector<int>g[MAXN];
int an;
int vis[MAXN];

int f(int nd)
{
    vis[nd] = 1;
    int cn = 1;
    for(auto i:g[nd])
    {
        if(vis[i]) continue;
        cn += f(i);
    }
   
    return cn;
}
void solve()
{

   cin >> n >> m;
   for(int i = 1;i <= m;i++)
   {
     int x,y;
     cin >> x >> y;
     g[x].pb(y);
   }
  
   for(int i = 1;i <= n;i++)
   {
       an += f(i);an--;
       an -= g[i].size();
       memset(vis,0,sizeof(vis));
   }

   cout<<an<<en;
}
int main()
{
    IOS;
   int t;
   t = 1;
    // cin >> t;
   int c = 0;
    while ( t-- )
    {
        // cout<<"Case "<<++c<<": ";
        solve();
    }
    return 0;
}   

Submission Info

Submission Time
Task E - Transitivity
User ar_rony1
Language C++ (GCC 9.2.1)
Score 500
Code Size 1311 Byte
Status AC
Exec Time 61 ms
Memory 3812 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:71:8: warning: unused variable ‘c’ [-Wunused-variable]
   71 |    int c = 0;
      |        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 51
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_srnd_00.txt, 01_srnd_01.txt, 01_srnd_02.txt, 01_srnd_03.txt, 01_srnd_04.txt, 01_srnd_05.txt, 01_srnd_06.txt, 01_srnd_07.txt, 02_rnd_00.txt, 02_rnd_01.txt, 02_rnd_02.txt, 02_rnd_03.txt, 02_rnd_04.txt, 02_rnd_05.txt, 02_rnd_06.txt, 02_rnd_07.txt, 03_smallM_00.txt, 03_smallM_01.txt, 03_smallM_02.txt, 03_smallM_03.txt, 03_smallM_04.txt, 04_largeM_00.txt, 04_largeM_01.txt, 04_largeM_02.txt, 04_largeM_03.txt, 04_largeM_04.txt, 05_zero_00.txt, 06_dag_00.txt, 06_dag_01.txt, 06_dag_02.txt, 06_dag_03.txt, 06_dag_04.txt, 06_dag_05.txt, 06_dag_06.txt, 06_dag_07.txt, 06_dag_08.txt, 06_dag_09.txt, 07_path_00.txt, 07_path_01.txt, 07_path_02.txt, 07_path_03.txt, 08_perfect_00.txt, 08_perfect_01.txt, 08_perfect_02.txt, 08_perfect_03.txt, 08_perfect_04.txt, 08_perfect_05.txt, 08_perfect_06.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 8 ms 3696 KiB
00_sample_01.txt AC 2 ms 3584 KiB
00_sample_02.txt AC 2 ms 3588 KiB
01_srnd_00.txt AC 3 ms 3680 KiB
01_srnd_01.txt AC 2 ms 3652 KiB
01_srnd_02.txt AC 2 ms 3712 KiB
01_srnd_03.txt AC 2 ms 3572 KiB
01_srnd_04.txt AC 2 ms 3532 KiB
01_srnd_05.txt AC 2 ms 3588 KiB
01_srnd_06.txt AC 2 ms 3648 KiB
01_srnd_07.txt AC 2 ms 3684 KiB
02_rnd_00.txt AC 4 ms 3556 KiB
02_rnd_01.txt AC 3 ms 3612 KiB
02_rnd_02.txt AC 3 ms 3648 KiB
02_rnd_03.txt AC 2 ms 3552 KiB
02_rnd_04.txt AC 3 ms 3592 KiB
02_rnd_05.txt AC 4 ms 3608 KiB
02_rnd_06.txt AC 3 ms 3592 KiB
02_rnd_07.txt AC 3 ms 3680 KiB
03_smallM_00.txt AC 2 ms 3572 KiB
03_smallM_01.txt AC 2 ms 3600 KiB
03_smallM_02.txt AC 2 ms 3592 KiB
03_smallM_03.txt AC 2 ms 3640 KiB
03_smallM_04.txt AC 3 ms 3636 KiB
04_largeM_00.txt AC 4 ms 3624 KiB
04_largeM_01.txt AC 3 ms 3616 KiB
04_largeM_02.txt AC 5 ms 3628 KiB
04_largeM_03.txt AC 3 ms 3648 KiB
04_largeM_04.txt AC 2 ms 3620 KiB
05_zero_00.txt AC 2 ms 3524 KiB
06_dag_00.txt AC 3 ms 3608 KiB
06_dag_01.txt AC 3 ms 3608 KiB
06_dag_02.txt AC 3 ms 3628 KiB
06_dag_03.txt AC 4 ms 3668 KiB
06_dag_04.txt AC 3 ms 3580 KiB
06_dag_05.txt AC 4 ms 3684 KiB
06_dag_06.txt AC 3 ms 3620 KiB
06_dag_07.txt AC 3 ms 3724 KiB
06_dag_08.txt AC 3 ms 3620 KiB
06_dag_09.txt AC 3 ms 3676 KiB
07_path_00.txt AC 32 ms 3744 KiB
07_path_01.txt AC 52 ms 3696 KiB
07_path_02.txt AC 40 ms 3812 KiB
07_path_03.txt AC 61 ms 3728 KiB
08_perfect_00.txt AC 3 ms 3680 KiB
08_perfect_01.txt AC 2 ms 3588 KiB
08_perfect_02.txt AC 2 ms 3608 KiB
08_perfect_03.txt AC 2 ms 3544 KiB
08_perfect_04.txt AC 2 ms 3608 KiB
08_perfect_05.txt AC 2 ms 3584 KiB
08_perfect_06.txt AC 2 ms 3652 KiB