답안 #1006778

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006778 2024-06-24T08:31:13 Z amin 가장 긴 여행 (IOI23_longesttrip) C++17
30 / 100
867 ms 848 KB
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> mer(vector<int>a,vector<int>b)
{
    vector<int>ans;
    reverse(b.begin(),b.end());
ans=a;
for(int i=0;i<b.size();i++)
{
    ans.push_back(b[i]);
}
return ans;
}
vector<int> longest_trip(int n, int d)
{
    int c[n][n];

    for(int i=0;i<n;i++)
    {
        c[i][i]=0;
        for(int y=0;y<i;y++)
        {
            if(are_connected({i},{y}))
                {
                    c[i][y]=1;
                    c[y][i]=1;

                }else
                {
                c[i][y]=0;
                c[y][i]=0;
                }

        }
    }
    vector<int>v1;
    vector<int>v2;
    v1.push_back(0);
    v2.push_back(1);
    for(int i=2;i<=n;i++)
    {
        int x=v1[v1.size()-1];
        int y=v2[v2.size()-1];
        if(c[x][y]==1)
        {
          //  cout<<1<<' '<<i<<endl;
            v1=mer(v1,v2);
            v2.clear();
            if(i!=n)
            v2.push_back(i);
            continue;
        }
        if(i==n)
            break;
        if(c[x][i]==1)
        {
            //cout<<2<<' '<<i<<endl;
            v1.push_back(i);
            continue;
        }
        if(c[y][i]==1)
        {
            //cout<<3<<' '<<i<<endl;
            v2.push_back(i);
            continue;
        }
    }

    if(v2.size()>v1.size())
        swap(v1,v2);
    return v1;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> mer(std::vector<int>, std::vector<int>)':
longesttrip.cpp:9:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | for(int i=0;i<b.size();i++)
      |             ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 189 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 24 ms 344 KB Output is correct
3 Correct 144 ms 344 KB Output is correct
4 Correct 415 ms 488 KB Output is correct
5 Correct 800 ms 668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 25 ms 344 KB Output is correct
3 Correct 162 ms 344 KB Output is correct
4 Correct 401 ms 472 KB Output is correct
5 Correct 792 ms 668 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 344 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Correct 174 ms 344 KB Output is correct
4 Correct 395 ms 344 KB Output is correct
5 Correct 715 ms 668 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 28 ms 344 KB Output is correct
8 Correct 142 ms 344 KB Output is correct
9 Correct 334 ms 468 KB Output is correct
10 Correct 834 ms 668 KB Output is correct
11 Correct 797 ms 848 KB Output is correct
12 Correct 832 ms 664 KB Output is correct
13 Correct 826 ms 600 KB Output is correct
14 Correct 7 ms 344 KB Output is correct
15 Correct 10 ms 344 KB Output is correct
16 Correct 39 ms 344 KB Output is correct
17 Correct 91 ms 344 KB Output is correct
18 Correct 128 ms 344 KB Output is correct
19 Correct 324 ms 484 KB Output is correct
20 Correct 299 ms 476 KB Output is correct
21 Correct 821 ms 672 KB Output is correct
22 Correct 782 ms 668 KB Output is correct
23 Correct 814 ms 664 KB Output is correct
24 Correct 842 ms 668 KB Output is correct
25 Correct 6 ms 344 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 34 ms 344 KB Output is correct
28 Correct 21 ms 344 KB Output is correct
29 Correct 26 ms 344 KB Output is correct
30 Correct 211 ms 344 KB Output is correct
31 Correct 178 ms 592 KB Output is correct
32 Correct 190 ms 344 KB Output is correct
33 Correct 310 ms 708 KB Output is correct
34 Correct 326 ms 592 KB Output is correct
35 Correct 291 ms 592 KB Output is correct
36 Correct 865 ms 676 KB Output is correct
37 Correct 807 ms 684 KB Output is correct
38 Correct 810 ms 668 KB Output is correct
39 Correct 747 ms 664 KB Output is correct
40 Correct 817 ms 668 KB Output is correct
41 Correct 757 ms 664 KB Output is correct
42 Correct 736 ms 660 KB Output is correct
43 Correct 768 ms 668 KB Output is correct
44 Correct 701 ms 668 KB Output is correct
45 Correct 6 ms 344 KB Output is correct
46 Correct 7 ms 344 KB Output is correct
47 Correct 31 ms 344 KB Output is correct
48 Correct 23 ms 344 KB Output is correct
49 Correct 35 ms 344 KB Output is correct
50 Correct 175 ms 344 KB Output is correct
51 Correct 207 ms 424 KB Output is correct
52 Correct 217 ms 344 KB Output is correct
53 Correct 307 ms 480 KB Output is correct
54 Correct 295 ms 452 KB Output is correct
55 Correct 264 ms 456 KB Output is correct
56 Correct 732 ms 664 KB Output is correct
57 Correct 867 ms 668 KB Output is correct
58 Correct 752 ms 664 KB Output is correct
59 Correct 767 ms 668 KB Output is correct
60 Correct 779 ms 668 KB Output is correct
61 Correct 807 ms 848 KB Output is correct
62 Correct 783 ms 668 KB Output is correct
63 Correct 738 ms 668 KB Output is correct
64 Correct 803 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 21 ms 344 KB Output is correct
3 Partially correct 134 ms 344 KB Output is partially correct
4 Partially correct 420 ms 592 KB Output is partially correct
5 Partially correct 797 ms 672 KB Output is partially correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -