답안 #844014

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844014 2023-09-04T21:56:26 Z LucaIlie 가장 긴 여행 (IOI23_longesttrip) C++17
5 / 100
723 ms 600 KB
#include "longesttrip.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 256;
int vis[MAX_N];
vector<pair<int, int>> pairs;
vector<int> ans;

vector<int> longest_trip( int n, int d ) {
    ans.clear();
    pairs.clear();
    for ( int u = 0; u < n; u++ )
        vis[u] = false;

    for ( int u = 0; u < n; u++ ) {
        for ( int v = u + 1; v < n; v++ ) {
            int x = are_connected( { u }, { v } );
            if ( !x ) {
                pairs.push_back( { u, v } );
                if ( vis[u] || vis[v] )
                    exit( 1 );
                vis[u] = vis[v] = true;
            }
        }
    }

    for ( int i = 0; i < pairs.size(); i++ )
        ans.push_back( pairs[i].first );
    for ( int u = 0; u < n; u++ ) {
        if ( !vis[u] )
            ans.push_back( u );
    }
    if ( n == 2 && pairs.size() == 1 )
        return ans;
    for ( int i = pairs.size() - 1; i >= 0; i-- )
        ans.push_back( pairs[i].second );

    return ans;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:29:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for ( int i = 0; i < pairs.size(); i++ )
      |                      ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 344 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 25 ms 344 KB Output is correct
3 Correct 114 ms 344 KB Output is correct
4 Correct 332 ms 344 KB Output is correct
5 Correct 723 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 26 ms 344 KB Output is correct
3 Correct 110 ms 344 KB Output is correct
4 Correct 353 ms 344 KB Output is correct
5 Correct 711 ms 412 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Incorrect 0 ms 344 KB Incorrect
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 21 ms 344 KB Output is correct
3 Correct 124 ms 344 KB Output is correct
4 Correct 351 ms 344 KB Output is correct
5 Correct 689 ms 412 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Incorrect 0 ms 344 KB Incorrect
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 24 ms 540 KB Output is correct
3 Partially correct 117 ms 344 KB Output is partially correct
4 Partially correct 346 ms 344 KB Output is partially correct
5 Partially correct 705 ms 416 KB Output is partially correct
6 Correct 6 ms 344 KB Output is correct
7 Incorrect 1 ms 344 KB Incorrect
8 Halted 0 ms 0 KB -