답안 #856911

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856911 2023-10-04T19:54:09 Z IS_Rushdi 가장 긴 여행 (IOI23_longesttrip) C++17
5 / 100
42 ms 1476 KB
#include<bits/stdc++.h>
using namespace std;
#include "longesttrip.h"

vector<int> longest_trip(int n, int k)
{
    vector<int>ans;
    if(k == 3) for(int i = 0; i < n; i++) ans.push_back(i);
    else if(k == 2){
        int v = 0;  ans.push_back(0);
        vector<int>a;
        for(int i = 1; i < n; i++) a.push_back(i);
        for(int i = 1; i < n; i++){
            vector<int>wow; wow.push_back(v);
            vector<int>arr = a;
            while(arr.size() > 1){
                int m = arr.size()/2;
                vector<int>newarr;
                for(int j = 0; j < m; j++) newarr.push_back(arr[j]);
                bool ok = are_connected(wow,newarr);
                if(ok){
                    arr = newarr;
                }else{
                    vector<int>newarr2;
                    for(int j = m; j < arr.size(); j++) newarr2.push_back(arr[j]);
                    arr = newarr2;
                }
            }
            vector<int>A;
            for(int i = 0; i < a.size(); i++){
                if(a[i] == arr[0]) continue;
                A.push_back(a[i]);
            }
            a = A;
            v = arr[0];
            ans.push_back(v);
        }
        
    }

    return ans;
}
// int main(){

// }

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:25:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |                     for(int j = m; j < arr.size(); j++) newarr2.push_back(arr[j]);
      |                                    ~~^~~~~~~~~~~~
longesttrip.cpp:30:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             for(int i = 0; i < a.size(); i++){
      |                            ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 8 ms 344 KB Output is correct
3 Correct 19 ms 608 KB Output is correct
4 Correct 29 ms 440 KB Output is correct
5 Correct 42 ms 1476 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -