제출 #919954

#제출 시각아이디문제언어결과실행 시간메모리
919954Lobo앵무새 (IOI11_parrots)C++17
컴파일 에러
0 ms0 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define fr first #define sc second // #define int long long // const int maxn = 1e5+10; // const int inf = 1e18+10; static vector<int> maxt; static int R; static int k; bool geq(vector<int> s, vector<int> t) { if(s.size() > t.size()) return 1; if(t.size() > s.size()) return 0; for(int i = (int) s.size() -1; i >= 0; i--) { if(s[i] > t[i]) return 1; if(t[i] > s[i]) return 0; } return 1; } vector<int> mult(vector<int> s, vector<int> t) { vector<int> ans((int) s.size()+(int) t.size(),0); if(s == vector<int>{0} or t == vector<int>{0}) return vector<int>{0}; for(int i = 0; i < s.size(); i++) { for(int j = 0; j < t.size(); j++) { ans[i+j]+= s[i]*t[j]; } } for(int i = 0; i < ans.size(); i++) { if(ans[i] >= 10) { if(i+1 == (int) ans.size()) ans.pb(0); ans[i+1]+= ans[i]/10; ans[i]%= 10; } } while(ans.size() > 1 && ans.back() == 0) ans.pop_back(); if(geq(ans,maxt)) return maxt; return ans; } vector<int> add(vector<int> s, vector<int> t) { vector<int> ans = s; for(int i = 0; i < t.size(); i++) { if(i == (int) ans.size()) ans.pb(0); ans[i]+= t[i]; } for(int i = 0; i < ans.size(); i++) { if(ans[i] >= 10) { if(i+1 == (int) ans.size()) ans.pb(0); ans[i+1]+= ans[i]/10; ans[i]%= 10; } } while(ans.size() > 1 && ans.back() == 0) ans.pop_back(); if(geq(ans,maxt)) return maxt; return ans; } vector<int> trans(int x) { if(x == 0) return vector<int>{0}; vector<int> ans; while(x != 0) { ans.pb(x%10); x/= 10; } return ans; } int transback(vector<int> s) { int ans = 0; int p10 = 1; for(int i = 0; i < s.size(); i++) { ans+= p10*s[i]; p10*= 10; } return ans; } vector<int> dp[260][10*64+10]; void precomp() { maxt.pb(1); for(int i = 0; i <= 77; i++) { maxt.pb(0); } // dp(i,sum) = # de (q_0,q_1,...,q_i) tal que a soma é no maximo sum for(int i = 0; i < R; i++) { for(int j = 0; j <= k; j++) { dp[i][j] = vector<int>{0}; } } for(int j = 0; j <= k; j++) { dp[0][j] = trans(j+1); } for(int i = 1; i < R; i++) { dp[i][0] = trans(1); for(int j = 1; j <= k; j++) { for(int x = 0; x <= j; x++) { dp[i][j] = add(dp[i][j],dp[i-1][j-x]); } } } } vector<int> querysmaller(vector<int> q) { vector<int> ans = {0}; int sumq = 0; for(int i = R-1; i >= 0; i--) { for(int j = 0; j <= q[i]-1 && k-j-sumq >= 0; j++) { if(i == 0) ans = add(ans,trans((int)1)); else ans = add(ans,dp[i-1][k-j-sumq]); } sumq+= q[i]; } if(sumq <= k) ans = add(ans,trans(1)); return ans; } vector<int> findg(vector<int> g) { vector<int> ans(R,0); int sumans = 0; for(int i = R-1; i >= 0; i--) { ans[i] = 0; for(int j = 1; j+sumans <= k; j++) { ans[i] = j; if(!(geq(g,querysmaller(ans)))) { ans[i] = j-1; break; } } sumans+= ans[i]; } return ans; } void encode(int32_t n, int32_t m[]) { k = 10*n; R = 100; precomp(); vector<int> vm = trans(0); vector<int> p256 = trans(1); for(int i = 0; i < n; i++) { vm = add(vm,mult(p256,trans(m[i]))); p256 = mult(p256,trans(256)); } vector<int> ans = findg(add(vm,trans(1))); for(int i = 0; i < ans.size(); i++) { for(int j = 0; j < ans[i]; j++) { send(i); } } }

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

encoder.cpp: In function 'std::vector<int> mult(std::vector<int>, std::vector<int>)':
encoder.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i = 0; i < s.size(); i++) {
      |                 ~~^~~~~~~~~~
encoder.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for(int j = 0; j < t.size(); j++) {
      |                  ~~^~~~~~~~~~
encoder.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for(int i = 0; i < ans.size(); i++) {
      |                 ~~^~~~~~~~~~~~
encoder.cpp: In function 'std::vector<int> add(std::vector<int>, std::vector<int>)':
encoder.cpp:52:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for(int i = 0; i < t.size(); i++) {
      |                 ~~^~~~~~~~~~
encoder.cpp:57:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(int i = 0; i < ans.size(); i++) {
      |                 ~~^~~~~~~~~~~~
encoder.cpp: In function 'int transback(std::vector<int>)':
encoder.cpp:83:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |  for(int i = 0; i < s.size(); i++) {
      |                 ~~^~~~~~~~~~
encoder.cpp: In function 'void encode(int32_t, int32_t*)':
encoder.cpp:168:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  168 |  for(int i = 0; i < ans.size(); i++) {
      |                 ~~^~~~~~~~~~~~

/usr/bin/ld: /tmp/ccEKyG1f.o: in function `main':
grader_decoder.cpp:(.text.startup+0x1ef): undefined reference to `decode(int, int, int*)'
collect2: error: ld returned 1 exit status