제출 #1128030

#제출 시각아이디문제언어결과실행 시간메모리
1128030_TemirhanLongest beautiful sequence (IZhO17_subsequence)C++20
0 / 100
316 ms327680 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define sz(x) x.size() #define F first #define S second #define nl '\n' void Tima() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } const int N = 3e5 + 1; const int inf = 1e12; const int mod = 998244353; signed main() { Tima(); ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >>n; int a[n + 1], k[n + 1]; vector< int >good[n + 1]; for( int i = 1; i <= n; ++i ) cin >>a[i]; for( int i = 1; i <= n; ++i ) { cin >>k[i]; for( int j = 1; j < i; ++j ) if( __builtin_popcount(a[j] & a[i]) == k[i] ) good[i].pb( j ); } vector< bool >us(n + 1, false); int mx = 1, p = 1; for( int i = n; i >= 1; --i ) { if( us[i] ) continue; int r = i, cnt = 1; us[i] = true; while( sz(good[r]) ) { ++cnt; r = good[r][sz(good[r]) - 1]; us[r] = true; } if( cnt > mx ) { mx = cnt; p = i; } } vector< int >ans; ans.pb( p ); while( sz(good[p]) ) { p = good[p][sz(good[p]) - 1]; ans.pb( p ); } reverse(ans.begin(), ans.end()); cout <<mx <<nl; for( int i: ans ) cout <<i <<' '; }

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

subsequence.cpp: In function 'void Tima()':
subsequence.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
subsequence.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...