제출 #527728

#제출 시각아이디문제언어결과실행 시간메모리
527728kaxzertLongest beautiful sequence (IZhO17_subsequence)C++17
0 / 100
5 ms3780 KiB
/** ⚡⚡ ⚡⚡ ⚡⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡⚡⚡⚡⚡ ⚡⚡⚡⚡⚡ ⚡⚡⚡⚡⚡⚡ ⚡⚡⚡⚡⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡⚡⚡ ⚡⚡⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡⚡⚡⚡⚡ ⚡⚡⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡⚡⚡⚡ ⚡⚡⚡⚡⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡⚡⚡⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡⚡⚡⚡⚡ ⚡⚡⚡⚡⚡ ⚡⚡ ⚡⚡ ⚡⚡ **/ #include<bits/stdc++.h> using namespace std; #define fto(i, a, b) for(int i = a; i <= b; ++i) #define fdto(i, a, b) for(int i = a; i >= b; --i) #define bugarr(a, i, j) cout << #a << "{" << i << "..." << j << "}:"; fto(k, i, j-1) cout << a[k] << ", "; cout << a[j] << endl; #define ll long long #define db double #define ldb long double #define ff first #define ss second #define pb push_back #define mp make_pair #define eb emplace_back #define vt vector #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define trav(i, a) for(auto &i : a) #define sz(a) (int)a.size() #define pi(a, b) pair<a, b> #define fast ios::sync_with_stdio(false); cin.tie(0) void setIO(string s) { if (sz(s) != 0) { freopen((s+".inp").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } } void setIOusaco(string s) { if (sz(s) != 0) { freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } } template<typename T, typename V> bool ckmin(T &a, V b) {return (b < a)? a = b, true : false;} template<typename T, typename V> bool ckmax(T &a, V b) {return (b > a)? a = b, true : false;} void print(int x) {cout << x;} void print(long long x) {cout << x;} void print(unsigned x) {cout << x;} void print(unsigned long long x) {cout << x;} void print(double x) {cout << fixed << x;} void print(long double x) {cout << fixed << x;} void print(char x) {cout << "'" << x << "'";} void print(string x) {cout << '"' << x << '"';} void print(bool x) {cout << (x ? "true" : "false");} template<typename T, typename V> void print(const pair<T, V> &x) {cout << '{'; print(x.ff); cout << ", "; print(x.ss); cout << '}';} template<typename T> void print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? ", " : ""), print(i); cout << "}";} void _print() {cout << "]" << endl;} template <typename T, typename... V> void _print(T t, V... v) {print(t); if (sizeof...(v)) cout << ", "; _print(v...);} #ifdef TAP #define bug(x...) cout << "[" << #x << "] = ["; _print(x) #else #define bug(x...) #endif pair<int, int> g[(1<<10) + 7][(1<<10) + 7][27]; int f[100008]; int main() { #ifndef TAP setIO(""); //setIOusaco("longest_beautiful_sequence"); #endif fast; int n; cin >> n; vt<int> a(n+1); vt<int> h(n+1); fto(i, 1, n) cin >> a[i]; fto(i, 1, n) cin >> h[i]; int ans = 0; int anspos; fto(j, 1, n) { int firsthalf = (a[j]&((1<<10)-1)); int secondhalf = (a[j]>>((1<<10)-1))&((1<<10)-1); int res = 0; int pos = 0; fto(i, 0, (1<<10)-1) { if (ckmax(res, g[i][secondhalf][h[j]-__builtin_popcount(firsthalf&i)].ff+1)) { pos = g[i][secondhalf][h[j]-__builtin_popcount(firsthalf&i)].ss; } } f[j] = pos; if (ckmax(ans, res)) { anspos = j; } fto(i, 0, (1<<10)-1) { if (ckmax(g[firsthalf][i][__builtin_popcount(secondhalf&i)].ff, res)) { g[firsthalf][i][__builtin_popcount(secondhalf&i)].ss = j; } } } cout << ans << '\n'; vt<int> trace; while(anspos != 0) { trace.pb(anspos); anspos = f[anspos]; } reverse(all(trace)); fto(i, 0, sz(trace)-1) { cout << trace[i] << " \n"[i == sz(trace)-1]; } return 0; }

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

subsequence.cpp: In function 'int main()':
subsequence.cpp:96:28: warning: right shift count >= width of type [-Wshift-count-overflow]
   96 |      int secondhalf = (a[j]>>((1<<10)-1))&((1<<10)-1);
subsequence.cpp: In function 'void setIO(std::string)':
subsequence.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen((s+".inp").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subsequence.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen((s+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subsequence.cpp: In function 'void setIOusaco(std::string)':
subsequence.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen((s+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subsequence.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen((s+".out").c_str(),"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...