Submission #696254

#TimeUsernameProblemLanguageResultExecution timeMemory
696254nicolexxuuLongest beautiful sequence (IZhO17_subsequence)C++14
Compilation error
0 ms0 KiB
import java.util.*; import java.io.*; public class subsequence { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int[] a = new int[n], k = new int[n]; st = new StringTokenizer(br.readLine()); for(int i = 0; i < n; i++) a[i] = Integer.parseInt(st.nextToken()); st = new StringTokenizer(br.readLine()); for(int i = 0; i < n; i++) k[i] = Integer.parseInt(st.nextToken()); br.close(); int[][][][] dp = new int[1<<10][1<<10][11][2]; int[][] res = new int[n][2]; for(int i = 0; i < n; i++) { int par = -1, ans = 0; int l = a[i] >> 10; int r = a[i] - (l << 10); for(int j = 0; j < (1 << 10); j++) { // possible prev lefts int bLeft = k[i] - Integer.bitCount(l&j); if(bLeft >= 0 && bLeft <= 10 ) { if(dp[l][r][bLeft][0] > ans) { ans = dp[l][r][bLeft][0]; par = dp[l][r][bLeft][1]; } } } res[i] = new int[] {ans+1, par}; for(int j = 0; j < (1 << 10); j++) { int b = Integer.bitCount(j&r); if(ans+1 > dp[l][j][b][0]) { dp[l][j][b][0] = ans+1; dp[l][j][b][1] = i; } } } // int idx = 0; // for(int i = 0; i < n; i++) idx = (res[i][0] > res[idx][0]) ? i : idx; // System.out.println(res[idx][0]); // ArrayDeque<Integer> l = new ArrayDeque<>(); // while(idx != -1) { // l.add(idx); // idx = res[idx][1]; // } // // StringBuilder sb = new StringBuilder(""); // while(!l.isEmpty()) sb.append(l.pollLast()+1).append(" "); // System.out.println(sb); } } /* 4 1 2 3 4 10 0 1 0 5 5 3 5 3 5 10 1 20 1 20 */

Compilation message (stderr)

subsequence.cpp:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
subsequence.cpp:2:1: error: 'import' does not name a type
    2 | import java.io.*;
      | ^~~~~~
subsequence.cpp:4:1: error: expected unqualified-id before 'public'
    4 | public class subsequence {
      | ^~~~~~