답안 #648354

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
648354 2022-10-06T08:34:25 Z berr The Collection Game (BOI21_swaps) C++17
12 / 100
94 ms 11596 KB
#include <bits/stdc++.h>
#include "swaps.h"
using namespace std;


void solve(int N, int V)
{
    vector<array<int, 2>> a[V];
    vector<vector<int>> vis(V, vector<int>(N+1));

    vector<int> ans(N+1), pos(N+1);

    for(int i=1; i<=N; i++) ans[i]=i, pos[i]=i;


    for(int i=1; i<=N; i++)
    {
        for(int l=i+1; l<=N; l++)
        {
            int flag=1;
            for(int j=0; j<V&&flag; j++)
            {
                if(vis[j][i]==0&&vis[j][l]==0)
                {
                    a[j].push_back({i, l});
                    vis[j][i]=1;
                    vis[j][l]=1;
                    flag=0;
                }
            }
        }
    }

    for(int i=0; i<V&&a[i].size(); i++)
    {
        for(auto l: a[i]) schedule(l[0], l[1]);
        auto b=visit();

        for(int l=0; l<a[i].size(); l++)
        {
            if(b[l]==0&&pos[a[i][l][0]]<pos[a[i][l][1]]) swap(ans[pos[a[i][l][0]]], ans[pos[a[i][l][1]]]), swap(pos[a[i][l][0]], pos[a[i][l][1]]);
            if(b[l]==1&&pos[a[i][l][0]]>pos[a[i][l][1]])swap(ans[pos[a[i][l][0]]], ans[pos[a[i][l][1]]]), swap(pos[a[i][l][0]], pos[a[i][l][1]]);
        }
    }

    vector<int> s;


    for(int i=1; i<=N; i++) s.push_back(ans[i]);

    answer(s);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int l=0; l<a[i].size(); l++)
      |                      ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 720 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 720 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 720 KB Correct
2 Correct 6 ms 2640 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 720 KB Correct
2 Correct 6 ms 2640 KB Correct
3 Incorrect 1 ms 720 KB Not correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 720 KB Correct
2 Correct 5 ms 2640 KB Correct
3 Correct 19 ms 5712 KB Correct
4 Correct 81 ms 11472 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 720 KB Correct
2 Correct 5 ms 2640 KB Correct
3 Correct 19 ms 5712 KB Correct
4 Correct 81 ms 11472 KB Correct
5 Incorrect 1 ms 720 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 720 KB Correct
2 Correct 5 ms 2640 KB Correct
3 Correct 20 ms 5812 KB Correct
4 Correct 90 ms 11596 KB Correct
5 Incorrect 75 ms 2488 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 720 KB Correct
2 Correct 5 ms 2640 KB Correct
3 Correct 20 ms 5812 KB Correct
4 Correct 90 ms 11596 KB Correct
5 Incorrect 75 ms 2488 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 876 KB Correct
2 Correct 5 ms 2552 KB Correct
3 Correct 18 ms 5824 KB Correct
4 Correct 80 ms 11484 KB Correct
5 Incorrect 81 ms 2420 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 876 KB Correct
2 Correct 5 ms 2552 KB Correct
3 Correct 18 ms 5824 KB Correct
4 Correct 80 ms 11484 KB Correct
5 Incorrect 81 ms 2420 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 720 KB Correct
2 Correct 4 ms 2640 KB Correct
3 Correct 18 ms 5760 KB Correct
4 Correct 94 ms 11584 KB Correct
5 Incorrect 78 ms 2372 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 720 KB Correct
2 Correct 4 ms 2640 KB Correct
3 Correct 18 ms 5760 KB Correct
4 Correct 94 ms 11584 KB Correct
5 Incorrect 78 ms 2372 KB Not correct
6 Halted 0 ms 0 KB -