Submission #307663

# Submission time Handle Problem Language Result Execution time Memory
307663 2020-09-29T04:04:33 Z cskitty Carnival (CEOI14_carnival) Java 11
100 / 100
481 ms 20968 KB
import java.io.*;
import java.util.*;
public class carnival
{
	static Reader sc=new Reader();
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        int n=sc.nextInt();
        ArrayList<Integer> locFirstVisit = new ArrayList<Integer>();
        int totalNew[] = new int[n+1];
        int arr[] = new int[n+1];
        int currCostNum = 0;
        for(int i = 1; i <= n; i++) {
        	System.out.print(i+" ");
        	for(int j = 1; j <= i; j++) {
        		System.out.print(j + " ");
        	}
        	System.out.flush();
        	int k = sc.nextInt();
        	totalNew[i] = k;
        	if(k > totalNew[i-1]) {
        		currCostNum++;
        		arr[i] = currCostNum;
        		locFirstVisit.add(i);
        	}else {
        		for(int j = 0; j < locFirstVisit.size(); j++) {
        			System.out.println("2 " + locFirstVisit.get(j) + " " + i);
        			int t = sc.nextInt();
        			if(t == 1) {
        				arr[i] = j+1;
        				break;
        			}
        		}
        	}
        }
        System.out.print(0 + " ");
        for(int i = 1; i <= n; i++) {
        	System.out.print(arr[i] + " ");
        }
        System.out.println();
    }
    
    static class Reader 
    { 
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        public int nextInt()
        {
            return Integer.parseInt(next());
        }
        public long nextLong()
        {
            return Long.parseLong(next());
        }
        public double nextDouble()
        {
            return Double.parseDouble(next());
        }
        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }
        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    } 
}
# Verdict Execution time Memory Grader output
1 Correct 325 ms 17032 KB Output is correct
2 Correct 399 ms 18896 KB Output is correct
3 Correct 481 ms 20968 KB Output is correct
4 Correct 193 ms 14604 KB Output is correct
5 Correct 212 ms 16780 KB Output is correct
6 Correct 220 ms 15768 KB Output is correct
7 Correct 297 ms 15608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 266 ms 15600 KB Output is correct
2 Correct 372 ms 17300 KB Output is correct
3 Correct 302 ms 15348 KB Output is correct
4 Correct 309 ms 17796 KB Output is correct
5 Correct 263 ms 16268 KB Output is correct
6 Correct 223 ms 14616 KB Output is correct
7 Correct 272 ms 16080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 214 ms 15532 KB Output is correct
2 Correct 304 ms 18880 KB Output is correct
3 Correct 466 ms 19796 KB Output is correct
4 Correct 242 ms 16904 KB Output is correct
5 Correct 270 ms 13516 KB Output is correct
6 Correct 250 ms 15828 KB Output is correct
7 Correct 289 ms 17436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 291 ms 18324 KB Output is correct
2 Correct 301 ms 16516 KB Output is correct
3 Correct 403 ms 19808 KB Output is correct
4 Correct 235 ms 17296 KB Output is correct
5 Correct 256 ms 16284 KB Output is correct
6 Correct 259 ms 16024 KB Output is correct
7 Correct 336 ms 16628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 282 ms 19464 KB Output is correct
2 Correct 416 ms 19428 KB Output is correct
3 Correct 407 ms 17552 KB Output is correct
4 Correct 422 ms 19524 KB Output is correct
5 Correct 244 ms 17280 KB Output is correct
6 Correct 256 ms 15848 KB Output is correct
7 Correct 300 ms 17668 KB Output is correct