제출 #1045826

#제출 시각아이디문제언어결과실행 시간메모리
1045826hirayuu_ojThe Collection Game (BOI21_swaps)C++17
25 / 100
52 ms852 KiB
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rng(i,l,r) for(int i=(l); i<(r); i++)
#define all(x) x.begin(),x.end()
using ll=long long;
#include "swaps.h"

void solve(int N, int V) {
    // TODO implement this function
    vector<int> find(N);
    iota(all(find),1);
    vector<int> ans;
    rep(i,N) {
        vector<int> now=find;
        while(now.size()>1) {
            vector<int> nxt;
            if(now.size()%2==1) {
                nxt={now.back()};
            }
            rep(j,now.size()/2) {
                schedule(now[j*2],now[j*2+1]);
            }
            vector<int> go=visit();
            rep(j,now.size()/2) {
                nxt.emplace_back(now[j*2+go[j]]);
            }
            now=nxt;
        }
        ans.emplace_back(now[0]);
        rep(i,find.size()) {
            if(find[i]==now[0]) {
                swap(find[i],find.back());
                find.pop_back();
                break;
            }
        }
    }
    reverse(all(ans));
    answer(ans);
}
/*
4 1000
1 2 3 4
0
1
0
1
1
0
0
1
1
1
0
0

*/

컴파일 시 표준 에러 (stderr) 메시지

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:3:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                                ^
swaps.cpp:21:13: note: in expansion of macro 'rep'
   21 |             rep(j,now.size()/2) {
      |             ^~~
swaps.cpp:3:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                                ^
swaps.cpp:25:13: note: in expansion of macro 'rep'
   25 |             rep(j,now.size()/2) {
      |             ^~~
swaps.cpp:3:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                                ^
swaps.cpp:31:9: note: in expansion of macro 'rep'
   31 |         rep(i,find.size()) {
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...