답안 #119396

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119396 2019-06-21T07:23:41 Z shayan_p 도서관 (JOI18_library) C++14
0 / 100
502 ms 892 KB
// High above the clouds there is a rainbow...

#include "library.h"

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=1010,mod=1e9+7;
const ll inf=1e18;

vector<int> v[maxn], mrk, ans;

int _Query(vector<int>&vec){
    bool any=0;
    for(int i=0;i<sz(vec);i++)
	any|= vec[i];
    if(any==0) return 0;
    return Query(vec);
}
    /*
void Answer(vector<int>&vec){
    for(int i=0;i<sz(vec);i++)
	cout<<vec[i]<<" ";
    cout<<endl;
    }*/

int solve(int l,int r,int x,int y){
    int n=r;
    ++r;
    while(r-l>1){
	int mid=(l+r)>>1;
	for(int i=0;i<n;i++)
	    mrk[i]=0;
	int cnt=0;
	for(int i=l;i<mid;i++)
	    mrk[i]= i!=x && i!=y, cnt+= i!=x && i!=y;
	int A=cnt- _Query(mrk);
	mrk[x]=1;
	int B=cnt+1- _Query(mrk);
	if(A==B) l=mid;
	else r=mid;
    }
    if(l==n) return -1;
    return l;
}

void Solve(int n){
    mrk.resize(n), ans.resize(n);    
    for(int i=0;i<n;i++){
	if(sz(v[i])==2) continue;     
	int j=solve(0,n,i, sz(v[i]) ? v[i][0] : -1);
	if(j!=-1) v[j].PB(i), v[i].PB(j);
    }
    for(int i=0;i<n;i++){
	mrk[i]=0;
    }
    for(int i=0;i<n;i++){
	if(sz(v[i])==1){
	    int cnt=0;
	    int tmp=i;
	    while(cnt<n){
		ans[cnt++]=tmp+1;
		mrk[tmp]=1;
		
		int nxt=-1;
		for(int j:v[tmp]){
		    if(mrk[j]==0) assert(nxt==-1), nxt=j;
		}
		tmp=nxt;
	    }
	    break;
	}
    }
    Answer(ans);
}
/*
int main(){
    int n; cin>>n;
    Solve(n);
    return 0;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Runtime error 37 ms 808 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 35 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 51 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 46 ms 732 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 36 ms 852 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 65 ms 604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 43 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 42 ms 728 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 41 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 23 ms 680 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Incorrect 2 ms 256 KB Wrong Answer [5]
12 Correct 2 ms 256 KB # of queries: 5
13 Correct 2 ms 256 KB # of queries: 10
14 Correct 2 ms 256 KB # of queries: 12
15 Correct 4 ms 384 KB # of queries: 111
16 Runtime error 8 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 37 ms 808 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 35 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 51 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 46 ms 732 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 36 ms 852 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 65 ms 604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 43 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 42 ms 728 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 41 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 23 ms 680 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Incorrect 2 ms 256 KB Wrong Answer [5]
12 Correct 2 ms 256 KB # of queries: 5
13 Correct 2 ms 256 KB # of queries: 10
14 Correct 2 ms 256 KB # of queries: 12
15 Correct 4 ms 384 KB # of queries: 111
16 Runtime error 8 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 463 ms 808 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 405 ms 892 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 463 ms 860 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 413 ms 736 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 439 ms 868 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 467 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 386 ms 752 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 142 ms 852 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 413 ms 868 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 395 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 127 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Correct 502 ms 504 KB # of queries: 19188
29 Correct 445 ms 484 KB # of queries: 19166
30 Correct 489 ms 480 KB # of queries: 19188