Submission #10347506


Source Code Expand

#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, M;
    cin >> N >> M;

    int E[N][N];
    REP(i, N) REP(j, N) E[i][j] = inf;


    int a[M], b[M];
    REP(i, M) {
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
        E[a[i]][b[i]] = 1;
        E[b[i]][a[i]] = 1;
    }

    int ans = 0;
    REP(l, M) {
        int tmp[N][N];
        REP(i, N) REP(j, N) {
            tmp[i][j] = E[i][j];
        }
        tmp[a[l]][b[l]] = inf;
        tmp[b[l]][a[l]] = inf;

        REP(k, N) REP(i, N) REP(j, N) {
            tmp[i][j] = min(tmp[i][j], tmp[i][k] + tmp[k][j]);
        }

        bool f = false;
        REP(i, N) {
            REP(j, N) {
                if (tmp[i][j] == inf) {
                    f = true;
                    break;
                }
            }
            if (f) break;
        }
        if (f) ++ans;
    }

    cout << ans << endl;
    
}

Submission Info

Submission Time
Task C - Bridge
User Ahykw
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1808 Byte
Status AC
Exec Time 9 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_1.txt AC 9 ms 256 KB
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt AC 3 ms 256 KB
subtask_1_12.txt AC 2 ms 256 KB
subtask_1_13.txt AC 9 ms 256 KB
subtask_1_14.txt AC 9 ms 256 KB
subtask_1_15.txt AC 9 ms 256 KB
subtask_1_16.txt AC 9 ms 256 KB
subtask_1_17.txt AC 9 ms 256 KB
subtask_1_2.txt AC 9 ms 256 KB
subtask_1_3.txt AC 2 ms 256 KB
subtask_1_4.txt AC 3 ms 256 KB
subtask_1_5.txt AC 3 ms 256 KB
subtask_1_6.txt AC 3 ms 256 KB
subtask_1_7.txt AC 7 ms 256 KB
subtask_1_8.txt AC 2 ms 256 KB
subtask_1_9.txt AC 1 ms 256 KB