Submission #336991

#TimeUsernameProblemLanguageResultExecution timeMemory
336991KWang31Xoractive (IZhO19_xoractive)Java
100 / 100
642 ms21404 KiB
import java.io.*; import java.util.*; public class Xoractive{ static int MOD=998244353; static int[] rk, p,siz; /* public static void main(String[] args){ int[] x= {1,1,6,6,7,7}; int[] y= {1,1,1,2,2,3,3,5,5,6,6,7,7}; System.out.println(ext(x,y)); } */ public static int[] guess(int n) { int[] ans=new int[n]; ans[0]=grader.ask(1);//Array is 1-indexed ArrayList<Integer> S[][]=new ArrayList[7][2]; ArrayList<Integer> cur=new ArrayList<>(); ArrayList<Integer> all=new ArrayList<>(); int[] c; for(int i=0;i<7;i++) {//Compute S[i][0] S[i][0]=new ArrayList<>(); cur=new ArrayList<>(); for(int j=1;j<n;j++) { if((j&(1<<i))==0) { cur.add(j+1);//1-indexed!! } } c=new int[cur.size()]; for(int j=0;j<cur.size();j++) c[j]=cur.get(j); int[] x=grader.get_pairwise_xor(c); c=new int[cur.size()+1]; for(int j=0;j<cur.size();j++) c[j]=cur.get(j); c[cur.size()]=1; int[] y=grader.get_pairwise_xor(c); int pter=0;while(pter<x.length && x[pter]==0) {pter++;}//Ignore zero elements int cnt=0; int jj; cur=ext(x,y); for(int j: cur) { j^=ans[0]; //if(i==0)System.out.println("element: "+j); if(S[i][0].contains(j))continue; S[i][0].add(j); if(!all.contains(j)) { all.add(j); } } //System.out.println(i+"..."+S[i][0]); } for(int i=0;i<7;i++) { S[i][1]=new ArrayList<>(); for(int j: all) { if(!S[i][0].contains(j)) { S[i][1].add(j); } } } for(int i=1; i<n;i++) { for(int j: S[0][i&1]) { boolean ok=true; for(int k=1; k<7; k++) { if(!S[k][(i>>>k)&1].contains(j)) { ok=false; break; } } if(ok) { ans[i]=j; break; } } } return ans; } public static ArrayList<Integer> ext(int[] x, int[] y){ int pter=0; while(pter<x.length && x[pter]==0)pter++; int jj; ArrayList<Integer> cur=new ArrayList<>(); for(int j=0; j<y.length; j++) { //System.out.println(j+" "+cur); if(y[j]==0)continue; jj=j; while(pter<x.length && jj<y.length && x[pter]==y[j] && y[j]==y[jj]) { pter++; jj++; } if(pter<x.length && jj<y.length && x[pter]>y[j] && y[jj]==y[j]) { cur.add(y[j]); while(jj<y.length && y[jj]==y[j])jj++; }else if(pter==x.length && jj<y.length && y[jj]==y[j]) { cur.add(y[j]); while(jj<y.length && y[jj]==y[j])jj++; } j=jj-1; //Compare //x=[1,1,2,2,2] //y=[1,1,2,2,3] } return cur; } } //Debugging: //Are you sure your algorithm is correct? //Bounds: long //Special cases: n=0,1? //Make sure you remove your debugging code before you submit!

Compilation message (stderr)

Note: Xoractive.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...