Submission #930392

# Submission time Handle Problem Language Result Execution time Memory
930392 2024-02-19T14:23:47 Z boris_mihov Making Friends on Joitter is Fun (JOI20_joitter2) C++17
0 / 100
8 ms 348 KB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <queue>
#include <set>
#include <map>

typedef long long llong;
const int MAXN = 50 + 10;
const int MAXM = 1250 + 10;
const int MOD = 1e9 + 7;

int n, m;
bool active[MAXN][MAXN];
int from[MAXM];
int to[MAXM];

void run()
{
    bool shouldCall = false;
    for (int x1 = 1 ; x1 <= n ; ++x1)
    {
        for (int x2 = 1 ; x2 <= n ; ++x2)
        {
            for (int x3 = 1 ; x3 <= n ; ++x3)
            {
                if (x1 == x2 || x2 == x3 || x1 == x3) continue;
                if (active[x1][x2] && active[x2][x3] && active[x3][x2] && !active[x1][x3])
                {
                    active[x1][x3] = true;
                    shouldCall = true;
                }
            }
        }
    }

    if (shouldCall)
    {
        run();
    }
}

int calc()
{
    int res = 0;
    for (int x1 = 1 ; x1 <= n ; ++x1)
    {
        for (int x2 = 1 ; x2 <= n ; ++x2)
        {
            res += active[x1][x2];
        }
    }
    
    return res;
}

void solve()
{
    for (int i = 1 ; i <= m ; ++i)
    {
        active[from[i]][to[i]] = true;
        run();

        std::cout << calc() << '\n';
    }
}

void input()
{
    std::cin >> n >> m;
    for (int i = 1 ; i <= m ; ++i)
    {
        std::cin >> from[i] >> to[i];
    }
}

void fastIOI()
{
    std::ios_base :: sync_with_stdio(0);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);
}

int main()
{
    fastIOI();
    input();
    solve();

    return 0;
}

/*
14 13
10 14
3 10
14 13
1 3
3 5
3 11
12 14
14 6
11 8
2 3
7 8
9 7
1 4

5 6
4 2
1 5
2 3
2 5
3 2
3 1
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Incorrect 8 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Incorrect 8 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Incorrect 8 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -