Submission #550558

# Submission time Handle Problem Language Result Execution time Memory
550558 2022-04-18T13:51:08 Z Pherokung Library (JOI18_library) C++14
19 / 100
474 ms 300 KB
#include <cstdio>
#include <vector>
#include "library.h"
#include<bits/stdc++.h>
using namespace std;
int adj[1005][2],st=1;
void Solve(int n){
	vector<int> res;
	if(n == 1){
		res.push_back(1);
		Answer(res);
		return;
	}
	vector<int> M(n), K, K2;
	for(int i=1;i<=n;i++){
		int be = 1, ed = n, mid, mi = 1e9;
		while(be <= ed){
			mid = (be+ed)/2;
//			printf(">> %d %d\n",i,mid);
			K = M;
			for(int j=1;j<=mid;j++) K[j-1] = 1;
			K2 = K;
			K[i-1] = 1, K2[i-1] = 0;
			
			
			int A;
			if(K2 == M) A = 0;
			else A = Query(K2);
			if(Query(K) <= A){
				ed = mid - 1;
				mi = min(mi,mid);
			}
			else be = mid + 1;
			
		}
		adj[i][0] = mi;
		
		be = mi+1, ed = n, mid;
		int mm = mi + 1;
		mi = 1e9;
		while(be <= ed){
			mid = (be+ed)/2;
			K = M;
			for(int j=mm;j<=mid;j++) K[j-1] = 1;
			K2 = K;
			K[i-1] = 1, K2[i-1] = 0;
			int A;
			if(K2 == M) A = 0;
			else A = Query(K2);
			
			if(Query(K) <= A){
				ed = mid - 1;
				mi = min(mi,mid);
			}
			else be = mid + 1;
		}
		
		if(mi == 1e9){
			adj[i][1] = -1;
			st = i;
		}
		else adj[i][1] = mi;
	}
	
	int pos = st, pre = -1;
	while(pos != -1){
		res.push_back(pos);
		
		int kk = pos;
		if(adj[pos][0] != pre) pos = adj[pos][0];
		else pos = adj[pos][1];
		pre = kk;
	}
	
	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:38:25: warning: right operand of comma operator has no effect [-Wunused-value]
   38 |   be = mi+1, ed = n, mid;
      |                         ^
# Verdict Execution time Memory Grader output
1 Correct 84 ms 208 KB # of queries: 5580
2 Correct 77 ms 208 KB # of queries: 5582
3 Correct 83 ms 208 KB # of queries: 5864
4 Correct 86 ms 208 KB # of queries: 5904
5 Correct 69 ms 208 KB # of queries: 5890
6 Correct 108 ms 208 KB # of queries: 5894
7 Correct 85 ms 208 KB # of queries: 5886
8 Correct 89 ms 208 KB # of queries: 5630
9 Correct 77 ms 208 KB # of queries: 5862
10 Correct 45 ms 284 KB # of queries: 3446
11 Correct 1 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 6
13 Correct 2 ms 208 KB # of queries: 20
14 Correct 1 ms 208 KB # of queries: 28
15 Correct 5 ms 208 KB # of queries: 214
16 Correct 8 ms 208 KB # of queries: 488
# Verdict Execution time Memory Grader output
1 Correct 84 ms 208 KB # of queries: 5580
2 Correct 77 ms 208 KB # of queries: 5582
3 Correct 83 ms 208 KB # of queries: 5864
4 Correct 86 ms 208 KB # of queries: 5904
5 Correct 69 ms 208 KB # of queries: 5890
6 Correct 108 ms 208 KB # of queries: 5894
7 Correct 85 ms 208 KB # of queries: 5886
8 Correct 89 ms 208 KB # of queries: 5630
9 Correct 77 ms 208 KB # of queries: 5862
10 Correct 45 ms 284 KB # of queries: 3446
11 Correct 1 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 6
13 Correct 2 ms 208 KB # of queries: 20
14 Correct 1 ms 208 KB # of queries: 28
15 Correct 5 ms 208 KB # of queries: 214
16 Correct 8 ms 208 KB # of queries: 488
17 Runtime error 474 ms 300 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -