답안 #771799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
771799 2023-07-03T09:33:17 Z CyberCow 철인 이종 경기 (APIO18_duathlon) C++17
0 / 100
1000 ms 19140 KB
//#include <bits/stdc++.h>
#include <random>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#define fr first
#define sc second
#define ad push_back
using namespace std;
using ll = long long;
mt19937 rnd(348502);
const int N = 300005;
vector<int> v[N];
int ans = 0;

void Dfs(int g, int x, int y, vector<int> &color)
{
    color[g] = 1;
    for (auto to : v[g])
    {
        if (color[x] == 0 && to == y)
            continue;
        if (color[to] == 0)
        {
            color[to] = 1;
            Dfs(to, x, y, color);
            color[to] = 0;
        }
    }
    if (color[y] == 1)
        ans = 1;
}

void solve()
{
    int n, i, j, x, y, m;
    cin >> n >> m;
    for ( i = 0; i < m; i++)
    {
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    vector<int> color;
    for ( i = 0; i <= n; i++)
    {
        color.push_back(0);
    }
    vector<int> c;
    int anss = 0;
    for ( i = 1; i <= n; i++)
    {
        for ( j = 1; j <= n; j++)
        {
            for (int h= 1; h <= n; h++)
            {
                if (j != i && h != j && i != h)
                {
                    c = color;
                    ans = 0;
                    //cout << i << ' ' << j << ' ' << h << '\n';
                    Dfs(i, j, h, c);
                    if (ans == 1)
                        anss++;
                }
            }
        }
    }
    cout << anss;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 3 ms 7252 KB Output is correct
3 Correct 3 ms 7364 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 3 ms 7252 KB Output is correct
6 Correct 3 ms 7252 KB Output is correct
7 Correct 3 ms 7364 KB Output is correct
8 Correct 8 ms 7372 KB Output is correct
9 Correct 231 ms 7348 KB Output is correct
10 Execution timed out 1073 ms 7252 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 3 ms 7252 KB Output is correct
3 Correct 3 ms 7364 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 3 ms 7252 KB Output is correct
6 Correct 3 ms 7252 KB Output is correct
7 Correct 3 ms 7364 KB Output is correct
8 Correct 8 ms 7372 KB Output is correct
9 Correct 231 ms 7348 KB Output is correct
10 Execution timed out 1073 ms 7252 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1056 ms 19140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1073 ms 7380 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 11516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 7380 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 11524 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 3 ms 7252 KB Output is correct
3 Correct 3 ms 7364 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 3 ms 7252 KB Output is correct
6 Correct 3 ms 7252 KB Output is correct
7 Correct 3 ms 7364 KB Output is correct
8 Correct 8 ms 7372 KB Output is correct
9 Correct 231 ms 7348 KB Output is correct
10 Execution timed out 1073 ms 7252 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 3 ms 7252 KB Output is correct
3 Correct 3 ms 7364 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 3 ms 7252 KB Output is correct
6 Correct 3 ms 7252 KB Output is correct
7 Correct 3 ms 7364 KB Output is correct
8 Correct 8 ms 7372 KB Output is correct
9 Correct 231 ms 7348 KB Output is correct
10 Execution timed out 1073 ms 7252 KB Time limit exceeded
11 Halted 0 ms 0 KB -