답안 #344020

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
344020 2021-01-05T04:46:08 Z amunduzbaev 도서관 (JOI18_library) C++14
19 / 100
360 ms 2028 KB
#include "library.h"
//#include "grader.cpp"
/** made by amunduzbaev **/
 
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vll vector<ll>
#define vii vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define cnt(a)__builtin_popcount(a)
template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;}
template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;}
 
const int N = 2e5+5;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
vector<int> m(N), used(N);

void Solve(int n){
	deque<int> ans;
	int l = 0;
	ans.push_back(l);
	m[l] = 1;
	used[l] = 1;
	m.resize(n);
	while(sz(ans) < n){
		bool ok = 0;
		for(int j=0;j<n;j++){
			if(used[j]) continue;
			m[j] = 1;
			//print();
			int res = Query(m);
			if(res == 1){
				used[j] = 1;
				ans.push_back(j);
				m[l] = 0;
				l = j;
				ok = 1;
				break;
			}else m[j] = 0;
		}
		if(!ok){
			m[l] = 0;
			l = 0;
			m[l] = 1;
			break;
		}
	}
	while(sz(ans) < n){
		for(int j=0;j<n;j++){
			if(used[j]) continue;
			m[j] = 1;
			//print();
			int res = Query(m);
			if(res == 1){
				used[j] = 1;
				ans.push_front(j);
				m[l] = 0;
				l = j;
				break;
			}else m[j] = 0;
		}
	}
	
	vector<int> res;
	for(int i=0;i<n;i++){
		int cur = ans.front();
		res.pb(cur+1);
		ans.pop_front();
	}
	
	Answer(res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 1900 KB # of queries: 9820
2 Correct 119 ms 1900 KB # of queries: 8651
3 Correct 86 ms 1948 KB # of queries: 9011
4 Correct 162 ms 1948 KB # of queries: 10227
5 Correct 180 ms 2028 KB # of queries: 9915
6 Correct 137 ms 1900 KB # of queries: 9269
7 Correct 155 ms 1948 KB # of queries: 9742
8 Correct 147 ms 1900 KB # of queries: 9697
9 Correct 156 ms 2028 KB # of queries: 9792
10 Correct 65 ms 1900 KB # of queries: 4359
11 Correct 1 ms 1900 KB # of queries: 0
12 Correct 1 ms 1900 KB # of queries: 1
13 Correct 1 ms 1900 KB # of queries: 3
14 Correct 1 ms 1900 KB # of queries: 4
15 Correct 3 ms 1900 KB # of queries: 75
16 Correct 4 ms 1900 KB # of queries: 193
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 1900 KB # of queries: 9820
2 Correct 119 ms 1900 KB # of queries: 8651
3 Correct 86 ms 1948 KB # of queries: 9011
4 Correct 162 ms 1948 KB # of queries: 10227
5 Correct 180 ms 2028 KB # of queries: 9915
6 Correct 137 ms 1900 KB # of queries: 9269
7 Correct 155 ms 1948 KB # of queries: 9742
8 Correct 147 ms 1900 KB # of queries: 9697
9 Correct 156 ms 2028 KB # of queries: 9792
10 Correct 65 ms 1900 KB # of queries: 4359
11 Correct 1 ms 1900 KB # of queries: 0
12 Correct 1 ms 1900 KB # of queries: 1
13 Correct 1 ms 1900 KB # of queries: 3
14 Correct 1 ms 1900 KB # of queries: 4
15 Correct 3 ms 1900 KB # of queries: 75
16 Correct 4 ms 1900 KB # of queries: 193
17 Runtime error 360 ms 1900 KB Execution killed with signal 13 (could be triggered by violating memory limits)
18 Halted 0 ms 0 KB -