제출 #873264

#제출 시각아이디문제언어결과실행 시간메모리
873264salmon순열 (APIO22_perm)C++17
컴파일 에러
0 ms0 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k){ if(k <= 90){ vector<int> v; for(int i = 0; i < k - 1; i++){ v.push_back(i); } reverse(v.begin(),v.end()); return v; } vector<int> v; vector<int> temp; vector<int> bits; bool flag = false; while(k != 0){ bits.push_back(k % 2); k /= 2; } bits.pop_back(); reverse(bits.begin(),bits.end()); if(bits[0] == 1){ flag = true; v.push_back(1); v.push_back(0); } else{ v.push_back(0); } for(int i = 1; i < bits.size(); i++){ if(flag){ if(bits[i] == 1 && i < bits.size() - 1 && bits[i + 1] == 1){ for(int i = 0; i < v.size(); i++){ if(v[i] >= 2){ v[i]++; } } v.push_back(v.size() + 1); v.push_back(v.size() + 1); v.push_back(2); i++; } else if(bits[i] == 0){ v.push_back(v.size()); } else{ temp.clear(); temp.push_back(v.size() + 1); for(int i : v){ temp.push_back(i); } temp.push_back(v.size()); v = temp; } } else{ if(bits[i] == 0){ temp.clear(); temp.push_back(0); for(int i : v){ temp.push_back(i + 1); } v = temp; } else{ temp.clear(); temp.push_back(1); for(int i : v){ temp.push_back(i + 2); } temp.push_back(0); v = temp; flag = true; } } } return v; } long long c(const vector<int>& v) { vector<long long> dp(v.size() + 1, 0); dp[0] = 1; for (int x : v) { for (int i = 0; i <= x; i++) { dp[x+1] += dp[i]; dp[x+1] = dp[x+1]; } } long long result = 0; for (int i = 0; i <= (int)v.size(); i++){ result += dp[i]; result = result; } return result; } int main(){ printf("%d",c(construct_permutation(16 + 8 + 2 + 1))); }

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i = 1; i < bits.size(); i++){
      |                    ~~^~~~~~~~~~~~~
perm.cpp:45:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             if(bits[i] == 1 && i < bits.size() - 1 && bits[i + 1] == 1){
      |                                ~~^~~~~~~~~~~~~~~~~
perm.cpp:46:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |                 for(int i = 0; i < v.size(); i++){
      |                                ~~^~~~~~~~~~
perm.cpp: In function 'int main()':
perm.cpp:126:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  126 |     printf("%d",c(construct_permutation(16 + 8 + 2 + 1)));
      |             ~^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |              |   |
      |              int long long int
      |             %lld
/usr/bin/ld: /tmp/ccy2e5lL.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccFNCq4L.o:perm.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status