| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 38266 | mirbek01 | Longest beautiful sequence (IZhO17_subsequence) | C++14 | 173 ms | 4108 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <bits/stdc++.h>
# define pb push_back
# define fr first
# define sc second
# define mk make_pair
using namespace std;
const long long linf = 1e18 + 7;
const int inf = 1e9 + 7;
const int N = 1e5 + 5;
typedef long long ll;
int n, a[N], k[N], dp[N], p[N], ot[N];
vector <int> ans;
int main(){
      cin >> n;
      for(int i = 1; i <= n; i ++){
            cin >> a[i];
            dp[i] = 1;
            ot[i] = i;
      }
      for(int i = 1; i <= n; i ++)
            cin >> k[i];
      if(n <= 5000){
            int pos = 0, mx = -1;
            for(int i = 1; i <= n; i ++)
            {
                  for(int j = i - 1; j >= 1; j --)
                  {
                        int bit = __builtin_popcount(a[i] & a[j]);
                        if(bit == k[i])
                        {
                              if(dp[i] <= dp[j])
                              {
                                    dp[i] = dp[j] + 1;
                                    ot[i] = j;
                              }
                        }
                  }
                  if(mx < dp[i])
                  {
                        mx = dp[i];
                        pos = i;
                  }
            }
            mx = pos;
            while(1)
            {
                  ans.pb(pos);
                  pos = ot[pos];
                  if(ans.size() >= dp[mx]) break;
            }
      } else {
            int pos = 0, mx = -1;
            for(int i = 1; i <= n; i ++){
                  for(int j = 0; j < 256; j ++)
                  {
                        int bit = __builtin_popcount(j & a[i]), d = p[j];
                        if(bit == k[i] && p)
                        {
                              if(dp[i] <= dp[d])
                              {
                                    dp[i] = dp[d] + 1;
                                    ot[i] = d;
                              }
                        }
                  }
                  p[a[i]] = i;
                  if(mx < dp[i])
                  {
                        mx = dp[i];
                        pos = i;
                  }
            }
            mx = pos;
            while(1)
            {
                  ans.pb(pos);
                  pos = ot[pos];
                  if(ans.size() >= dp[mx]) break;
            }
      }
      cout << ans.size() << endl;
      reverse(ans.begin(), ans.end());
      for(int i : ans)
            cout << i << " ";
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
