답안 #419236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
419236 2021-06-06T15:08:33 Z usachevd0 조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2) C++17
0 / 100
5000 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define Time (clock() * 1.0 / CLOCKS_PER_SEC)
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using ld = long double;
template<typename T1, typename T2> bool chkmin(T1& x, T2 y) {
    return y < x ? (x = y, true) : false;
}
template<typename T1, typename T2> bool chkmax(T1& x, T2 y) {
    return y > x ? (x = y, true) : false;
}
void debug_out() {
    cerr << endl;
}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) {
    cerr << ' ' << A;
    debug_out(B...);
}
template<typename T> void mdebug_out(T* a, int n) {
    for (int i = 0; i < n; ++i)
        cerr << a[i] << ' ';
    cerr << endl;
}
#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    #define mdebug(a, n) cerr << #a << ": ", mdebug_out(a, n)
#else
    #define debug(...) 1337
    #define mdebug(a, n) 1337
#endif
template<typename T> ostream& operator << (ostream& stream, const vector<T>& v) {
    for (auto& x : v)
        stream << x << ' ';
    return stream;
}
template<typename T1, typename T2> ostream& operator << (ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << ' ' << p.second;
}

const int maxN = 100;
int n, m;
bool G[maxN][maxN], H[maxN][maxN];


int32_t main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a][b] = 1;
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                H[i][j] = G[i][j];
        int ans = i + 1;
        while (true) {
            int added = false;
            for (int a = 0; a < n && !added; ++a)
                for (int b = 0; b < n && !added; ++b)
                    if (a != b)
                        for (int c = 0; c < n && !added; ++c)
                            if (c != a && c != b)
                                if (H[a][b] && H[b][c] && H[c][b] && !H[a][c]) {
                                    H[a][c] = 1;
                                    ++ans;
                                    added = true;
                                }
            if (!added) break;
        }
        cout << ans << '\n';
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 6 ms 328 KB Output is correct
6 Correct 5 ms 204 KB Output is correct
7 Execution timed out 5010 ms 340 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 6 ms 328 KB Output is correct
6 Correct 5 ms 204 KB Output is correct
7 Execution timed out 5010 ms 340 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 6 ms 328 KB Output is correct
6 Correct 5 ms 204 KB Output is correct
7 Execution timed out 5010 ms 340 KB Time limit exceeded
8 Halted 0 ms 0 KB -