Submission #844016

# Submission time Handle Problem Language Result Execution time Memory
844016 2023-09-04T21:58:30 Z LucaIlie Longest Trip (IOI23_longesttrip) C++17
15 / 100
783 ms 592 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 = 0; i < pairs.size(); 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++ )
      |                      ~~^~~~~~~~~~~~~~
longesttrip.cpp:37: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]
   37 |     for ( int i = 0; i < pairs.size(); i++ )
      |                      ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 26 ms 344 KB Output is correct
3 Correct 111 ms 344 KB Output is correct
4 Correct 319 ms 344 KB Output is correct
5 Correct 741 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 20 ms 344 KB Output is correct
3 Correct 127 ms 344 KB Output is correct
4 Correct 372 ms 344 KB Output is correct
5 Correct 763 ms 408 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 21 ms 344 KB Output is correct
8 Correct 129 ms 344 KB Output is correct
9 Correct 257 ms 592 KB Output is correct
10 Correct 717 ms 416 KB Output is correct
11 Correct 755 ms 412 KB Output is correct
12 Correct 707 ms 412 KB Output is correct
13 Correct 733 ms 412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 21 ms 344 KB Output is correct
3 Correct 123 ms 344 KB Output is correct
4 Correct 333 ms 344 KB Output is correct
5 Correct 768 ms 408 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 23 ms 344 KB Output is correct
8 Correct 116 ms 344 KB Output is correct
9 Correct 261 ms 428 KB Output is correct
10 Correct 743 ms 592 KB Output is correct
11 Correct 679 ms 592 KB Output is correct
12 Correct 703 ms 408 KB Output is correct
13 Correct 757 ms 412 KB Output is correct
14 Runtime error 0 ms 344 KB Execution failed because the return code was nonzero
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 23 ms 344 KB Output is correct
3 Partially correct 124 ms 344 KB Output is partially correct
4 Partially correct 371 ms 344 KB Output is partially correct
5 Partially correct 749 ms 408 KB Output is partially correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Partially correct 117 ms 344 KB Output is partially correct
9 Partially correct 292 ms 408 KB Output is partially correct
10 Partially correct 783 ms 408 KB Output is partially correct
11 Partially correct 746 ms 408 KB Output is partially correct
12 Partially correct 752 ms 408 KB Output is partially correct
13 Partially correct 744 ms 412 KB Output is partially correct
14 Runtime error 0 ms 344 KB Execution failed because the return code was nonzero
15 Halted 0 ms 0 KB -