답안 #886394

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886394 2023-12-12T03:12:11 Z anhphant 철인 이종 경기 (APIO18_duathlon) C++14
0 / 100
1000 ms 24224 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int inN, inM;
vector<int> inGR[100007];

namespace subtask1 {
    int N, M;
    bool havepath[17][17][17], visited[17];
    vector<int> GR[100007];
    ll ans = 0;

    void backtrack2(ll finish, ll mid, ll start) {
        if (finish != mid) {
            havepath[start][mid][finish] = 1;
        }

        for(int nxtfinish : GR[finish]) {
            if (visited[nxtfinish]) continue;
            visited[nxtfinish] = 1;
            backtrack2(nxtfinish, mid, start);
            visited[nxtfinish] = 0;
        }
    }

    void backtrack(ll mid, ll start) {
        if (mid != start) {
            backtrack2(mid, mid, start);
        }

        for(int nxtmid : GR[mid]) {
            if (visited[nxtmid]) continue;
            visited[nxtmid] = 1;
            backtrack(nxtmid, start);
            visited[nxtmid] = 0;
        }
    }

    void preprocess() {
        N = inN;
        M = inM;
        for(int i = 1; i <= N; ++i) GR[i] = inGR[i];
    }

    void solve() {
        for(int i = 1; i <= N; ++i) {
            visited[i] = 1;
            backtrack(i, i);
            visited[i] = 0;
        }

        for(int i = 1; i <= N; ++i) {
            for(int j = 1; j <= N; ++j) {
                for(int k = 1; k <= N; ++k) {
                    ans += havepath[i][j][k];
                }
            }
        }

        cout << ans << endl;
    }

    void process() {
        preprocess();
        solve();
    }
}

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0); cerr.tie(0);
    if (fopen("FILE.INP", "r")) {
        freopen("FILE.INP", "r", stdin);
        freopen("FILE.OUT", "w", stdout);
    }

    cin >> inN >> inM;
    for(int i = 1, u, v; i <= inM; ++i) {
        cin >> u >> v;
        inGR[u].push_back(v);
        inGR[v].push_back(u);
    }

    subtask1 :: process();
}

Compilation message

count_triplets.cpp: In function 'int main()':
count_triplets.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         freopen("FILE.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
count_triplets.cpp:76:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         freopen("FILE.OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4964 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 41 ms 4952 KB Output is correct
10 Execution timed out 1081 ms 4952 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4964 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 41 ms 4952 KB Output is correct
10 Execution timed out 1081 ms 4952 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 32 ms 23988 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 17 ms 10096 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 44 ms 24144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 14 ms 10072 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 61 ms 24224 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4964 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 41 ms 4952 KB Output is correct
10 Execution timed out 1081 ms 4952 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4964 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 41 ms 4952 KB Output is correct
10 Execution timed out 1081 ms 4952 KB Time limit exceeded
11 Halted 0 ms 0 KB -