제출 #167756

#제출 시각아이디문제언어결과실행 시간메모리
167756abilLongest beautiful sequence (IZhO17_subsequence)C++14
0 / 100
17 ms1788 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (1e5 + 12); const int m = (1 << 10); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); pair<int,int > dp[m][m][11]; int a[N], path[N], k[N], bit[m]; main() { int n; scanf("%d", &n); for(int i = 1;i <= n; i++){ scanf("%d", &a[i]); } for(int i = 1;i <= n; i++){ scanf("%d", &k[i]); } for(int i = 0;i < m; i++){ bit[i] = __builtin_popcount(i); } int ans = 0, ansid; for(int i = 1;i <= n; i++){ int pr = (a[i] >> 10); int sf = (a[i] % m); int mx = 1, id = 0; for(int j = 0;j < m; j++){ int need = k[i] - bit[j & pr]; if(need < 0){ continue; } if(mx < dp[j][sf][need].fr + 1){ mx = dp[j][sf][need].fr + 1; id = dp[j][sf][need].sc; } } path[i] = id; for(int j = 0;j < m; j++){ int need = bit[j & sf]; if(dp[pr][j][need].fr < mx){ dp[pr][j][need] = {mx,i}; } } if(mx > ans){ ans = mx; ansid = i; } } printf("%d\n", ans); vector<int > vec; while(ansid){ vec.pb(ansid); ansid = path[ansid]; } reverse(all(vec)); for(auto to : vec){ printf("%d ", to); } }

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

subsequence.cpp:19:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
subsequence.cpp: In function 'int main()':
subsequence.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
subsequence.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
subsequence.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &k[i]);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...