Submission #1370355


Source Code Expand

#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 1e5 + 10;
const int M = (int) 101;
const ll big =  (1LL << 51);
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int INF1 = (int) 1e9 + 3;
const double EPS = (double) 1e-6;
const double PI =  3.14159265359;

int n, m;
vector<int> v[N];
bool u[N];

void dfs(int x) {
  u[x] = 1;
  for (auto it : v[x]) {
    if (!u[it]) dfs(it);
  }
}

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    cin >> n >> m;
    vector<pii> e;
    while (m--) {
      int x, y;
      cin >> x >> y;
      --x, --y;
      e.pb({x, y});
      e.pb({y, x});
    }
    for (int i = 0; i < sz(e); i++) {
      for (int j = 0; j < sz(e); j++) {
        v[e[i].f * n + e[j].f].pb(e[i].s * n + e[j].s);
      }
    }
    int comp = 0;
    for (int i = 0; i < n * n; i++) {
      if (!u[i]) {
        dfs(i);
        ++comp;
      }
    }
    cout << comp;
    return 0;
}

Submission Info

Submission Time
Task C - Squared Graph
User Nurlykhan
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1469 Byte
Status RE
Exec Time 208 ms
Memory 8816 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
AC × 2
AC × 10
RE × 22
Set Name Test Cases
Sample sample1.txt, sample2.txt
All sample1.txt, sample2.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt
Case Name Status Exec Time Memory
in1.txt AC 3 ms 2688 KB
in10.txt RE 98 ms 2688 KB
in11.txt AC 3 ms 2816 KB
in12.txt RE 125 ms 3704 KB
in13.txt RE 126 ms 3704 KB
in14.txt RE 153 ms 4724 KB
in15.txt RE 102 ms 2816 KB
in16.txt RE 139 ms 4724 KB
in17.txt RE 128 ms 3704 KB
in18.txt RE 176 ms 8816 KB
in19.txt RE 153 ms 4724 KB
in2.txt AC 4 ms 3072 KB
in20.txt RE 153 ms 4724 KB
in21.txt RE 208 ms 7024 KB
in22.txt RE 195 ms 8560 KB
in23.txt RE 183 ms 8176 KB
in24.txt RE 98 ms 2560 KB
in25.txt RE 208 ms 7280 KB
in26.txt AC 4 ms 3072 KB
in27.txt RE 98 ms 2688 KB
in28.txt RE 208 ms 8304 KB
in3.txt AC 6 ms 3456 KB
in4.txt AC 10 ms 4992 KB
in5.txt RE 190 ms 7536 KB
in6.txt RE 102 ms 2816 KB
in7.txt RE 101 ms 2816 KB
in8.txt RE 108 ms 2944 KB
in9.txt RE 130 ms 3704 KB
sample1.txt AC 2 ms 2560 KB
sample2.txt AC 2 ms 2560 KB