Submission #19387114


Source Code Expand

//SAGAR SINGH

#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio;cin.tie(NULL);cout.tie(0);
#define ll long long 
#define ld long double 
#define rep(i,a,b) for(ll i=a;i<b;i++) //rep(i,0,n) 
#define repr(i,a,b) for(ll i=a;i>=b;i--)//repr(i,n-1,0)
#define repit(it,a) for(auto it=(a).begin();it!=(a).end();it++)//repr(i,n,0)
#define vll vector<long long>
#define vpl vector<pair<ll,ll> >
#define sll set<long long>
#define msll multiset<long long>
#define mll map<ll,ll>
#define mmll multimap<ll,ll>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define get(x) getline(cin,x)
#define in(v) for(auto &x:v) cin>>x;
#define out(v) for(auto x:v) {cout<<x<<" ";} cout<<"\n";
#define str string
#define pb  push_back
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define mod 1000000007
#define maxx 1e7+7
/*--- bit-stuff ----*/
#define setbits(a) ( __builtin_popcountll(a))
#define right(a) (__builtin_ctzll(a))
#define left(a) (__builtin_clzll(a))
#define parity(a) (__builtin_parityll(a))

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

vll adj[200001];
bool visited[200001];
void dfs(ll u ) {
     
    visited[u] = 1;
    for (ll v : adj[u]) {
        if (!visited[v])
            dfs(v );
    }
}

int main(){
   fastio
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif

// ll t;cin>>t;while(t--){

ll n;cin>>n;
sll s;
rep(i,0,n){
  ll x,y;cin>>x>>y;
  s.ins(x);
  s.ins(y);
  adj[x].pb(y);
  adj[y].pb(x);
}
ll c=0;
// ll trees=0;

for(auto x:s){
if(!visited[x])
{
  dfs(x);
  c++;
}
}
// trace(c,s.size());
if(c==1&&(n==((s.size())-1))) cout <<s.size()-1;
else cout<<s.size();









 
 


// }

#ifndef ONLINE_JUDGE
   cout<<"\n\n\nTime lap: "<<1.0*clock()/CLOCKS_PER_SEC<<" sec\n";
  #endif
return 0;
}

Submission Info

Submission Time
Task B - Reversible Cards
User Sagar_
Language C++ (GCC 9.2.1)
Score 0
Code Size 2479 Byte
Status RE
Exec Time 347 ms
Memory 25084 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:5:26: warning: statement is a reference, not call, to function ‘std::ios_base::sync_with_stdio’ [-Waddress]
    5 | #define fastio ios_base::sync_with_stdio;cin.tie(NULL);cout.tie(0);
      |                ~~~~~~~~~~^~~~~~~~~~~~~~~
./Main.cpp:65:4: note: in expansion of macro ‘fastio’
   65 |    fastio
      |    ^~~~~~
./Main.cpp:5:26: warning: statement has no effect [-Wunused-value]
    5 | #define fastio ios_base::sync_with_stdio;cin.tie(NULL);cout.tie(0);
      |                ~~~~~~~~~~^~~~~~~~~~~~~~~
./Main.cpp:65:4: note: in expansion of macro ‘fastio’
   65 |    fastio
      |    ^~~~~~
./Main.cpp:93:12: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::set<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   93 | if(c==1&&(n==((s.size())-1))) cout <<s.size()-1;
      |           ~^~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 16
WA × 4
RE × 7
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt
Case Name Status Exec Time Memory
0_000.txt AC 13 ms 8196 KiB
0_001.txt AC 7 ms 8168 KiB
0_002.txt AC 13 ms 8192 KiB
1_003.txt WA 7 ms 8124 KiB
1_004.txt AC 7 ms 8068 KiB
1_005.txt AC 72 ms 11820 KiB
1_006.txt WA 9 ms 8324 KiB
1_007.txt AC 10 ms 8296 KiB
1_008.txt AC 102 ms 12448 KiB
1_009.txt RE 116 ms 7960 KiB
1_010.txt RE 115 ms 7808 KiB
1_011.txt RE 114 ms 7940 KiB
1_012.txt RE 196 ms 23568 KiB
1_013.txt RE 184 ms 15780 KiB
1_014.txt RE 112 ms 7808 KiB
1_015.txt RE 170 ms 16528 KiB
1_016.txt AC 11 ms 8140 KiB
1_017.txt AC 45 ms 10560 KiB
1_018.txt AC 87 ms 13912 KiB
1_019.txt AC 278 ms 25028 KiB
1_020.txt AC 290 ms 25060 KiB
1_021.txt AC 9 ms 8216 KiB
1_022.txt AC 11 ms 8072 KiB
1_023.txt AC 242 ms 21408 KiB
1_024.txt WA 121 ms 16272 KiB
1_025.txt AC 347 ms 25084 KiB
1_026.txt WA 160 ms 18544 KiB