제출 #731991

#제출 시각아이디문제언어결과실행 시간메모리
731991parsadox2순열 (APIO22_perm)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define debug(x) cout << #x << "= " << x << ", " #define ll long long #define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define SZ(x) (int) x.size() #define wall cout << endl; using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); string inttostr(int x) { int k = 1; while(k * 2 <= x) k *= 2; string res; for(int i = k ; i > 0 ; i >>= 1) { if((x & i) != 0) res.pb('1'); else res.pb('0'); } return res; } vector <int> construct_permutation(int k) { vector <int> res; if(k <= 10) { for(int i = k - 2 ; i >= 0 ; i--) res.pb(i); return res; } string s = inttostr(k); int ps; if(s[1] == '1') { res = {1 , 0}; ps = 2; } else if(s[2] == '0') { res = {2 , 1 , 0}; ps = 3; } else { res = {1 , 2 , 0}; ps = 3; } while(ps < SZ(s)) { if(ps + 1 == SZ(s)) { res.pb(SZ(res)); if(s[ps] == '1') { for(int i = 0 ; i < SZ(res) ; i++) res[i]++; res.pb(0); } break; } else if(s[ps] == '0' && s[ps + 1] == '0') { res.pb(SZ(res)); res.pb(SZ(res)); } else if(s[ps] == '0' && s[ps + 1] == '1') { res.pb(SZ(res)); res.pb(SZ(res)); for(int i = 0 ; i < SZ(res) ; i++) res[i]++; res.pb(0); } else if(s[ps] == '1' && s[ps + 1] == '0') { res.pb(SZ(res)); for(int i = 0 ; i < SZ(res) ; i++) res[i]++; res.pb(0); res.pb(SZ(res)); } else if(s[ps] == '1' && s[ps + 1] == '1') { res.pb(SZ(res)); res.pb(SZ(res)); for(int i = 0 ; i < SZ(res) ; i++) if(res[i] > 1) res[i]++; res.pb(2); } ps += 2; } return res; }

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

/usr/bin/ld: /tmp/ccMBJYQI.o: in function `main':
grader.cpp:(.text.startup+0x240): undefined reference to `construct_permutation(long long)'
collect2: error: ld returned 1 exit status