답안 #232634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
232634 2020-05-17T17:36:34 Z kshitij_sodani Xylophone (JOI18_xylophone) C++17
100 / 100
99 ms 632 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#include "xylophone.h"
/*void answer(int x,int y){
	cout<<x<<","<<y<<endl;
}
int query(int x,int y){
	cout<<x<<" "<<y<<endl;
	int yy;
	cin>>yy;
	return yy;
}*/
void solve(int n){
	if(n==2){
		answer(1,1);
		answer(2,2);
		return ;
	}
	int aa[n];
	for(int i=0;i<n-1;i++){
		aa[i]=query(i+1,i+2);
	}
	int bb[n];
	for(int i=0;i<n-2;i++){
		bb[i]=query(i+1,i+3);
	}
	int ans[n];
	ans[0]=0;
	int le=0;
	for(int i=0;i<n-1;i++){
		if(le==0){
			ans[i+1]=ans[i]+aa[i];
		}
		else{
			ans[i+1]=ans[i]-aa[i];
		}
		if(i<n-2){
			if(bb[i]==max(aa[i],aa[i+1])){
				le=1-le;
			}
		}
	}
	int mi;
/*	for(int i=0;i<n;i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;*/
	for(int i=0;i<n;i++){
		if(i==0){
			mi=ans[i];
		}
		else{
			mi=min(mi,ans[i]);
		}
	}
	int ind;
	int ind2;
	for(int i=0;i<n;i++){
		ans[i]+=(-mi+1);
		if(ans[i]==1){
			ind=i;
		}
		if(ans[i]==n){
			ind2=i;
		}
	}
	if(ind<ind2){
	//	cout<<11<<endl;
		for(int i=0;i<n;i++){
			answer(i+1,ans[i]);
		}
		return;
	}
	ans[0]=0;
	le=1;
	for(int i=0;i<n-1;i++){
		if(le==0){
			ans[i+1]=ans[i]+aa[i];
		}
		else{
			ans[i+1]=ans[i]-aa[i];
		}
		if(i<n-2){
			if(bb[i]==max(aa[i],aa[i+1])){
				le=1-le;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(i==0){
			mi=ans[i];
		}
		else{
			mi=min(mi,ans[i]);
		}
	}
	for(int i=0;i<n;i++){
		ans[i]+=(-mi+1);
		if(ans[i]==1){
			ind=i;
		}
		if(ans[i]==n){
			ind2=i;
		}
	}
		for(int i=0;i<n;i++){
			answer(i+1,ans[i]);
		}
		return;


}
/*int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve(5);

	
	return 0;
}*/

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:73:2: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if(ind<ind2){
  ^~
xylophone.cpp:73:2: warning: 'ind2' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 6 ms 256 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 6 ms 256 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 256 KB Output is correct
16 Correct 8 ms 256 KB Output is correct
17 Correct 12 ms 256 KB Output is correct
18 Correct 21 ms 368 KB Output is correct
19 Correct 20 ms 376 KB Output is correct
20 Correct 21 ms 376 KB Output is correct
21 Correct 19 ms 256 KB Output is correct
22 Correct 25 ms 384 KB Output is correct
23 Correct 21 ms 384 KB Output is correct
24 Correct 21 ms 376 KB Output is correct
25 Correct 21 ms 384 KB Output is correct
26 Correct 19 ms 380 KB Output is correct
27 Correct 22 ms 384 KB Output is correct
28 Correct 23 ms 376 KB Output is correct
29 Correct 22 ms 376 KB Output is correct
30 Correct 27 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 6 ms 256 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 256 KB Output is correct
16 Correct 8 ms 256 KB Output is correct
17 Correct 12 ms 256 KB Output is correct
18 Correct 21 ms 368 KB Output is correct
19 Correct 20 ms 376 KB Output is correct
20 Correct 21 ms 376 KB Output is correct
21 Correct 19 ms 256 KB Output is correct
22 Correct 25 ms 384 KB Output is correct
23 Correct 21 ms 384 KB Output is correct
24 Correct 21 ms 376 KB Output is correct
25 Correct 21 ms 384 KB Output is correct
26 Correct 19 ms 380 KB Output is correct
27 Correct 22 ms 384 KB Output is correct
28 Correct 23 ms 376 KB Output is correct
29 Correct 22 ms 376 KB Output is correct
30 Correct 27 ms 376 KB Output is correct
31 Correct 38 ms 376 KB Output is correct
32 Correct 58 ms 384 KB Output is correct
33 Correct 83 ms 384 KB Output is correct
34 Correct 89 ms 384 KB Output is correct
35 Correct 87 ms 384 KB Output is correct
36 Correct 75 ms 376 KB Output is correct
37 Correct 78 ms 384 KB Output is correct
38 Correct 84 ms 384 KB Output is correct
39 Correct 84 ms 376 KB Output is correct
40 Correct 88 ms 384 KB Output is correct
41 Correct 86 ms 384 KB Output is correct
42 Correct 75 ms 384 KB Output is correct
43 Correct 99 ms 384 KB Output is correct
44 Correct 83 ms 396 KB Output is correct
45 Correct 76 ms 516 KB Output is correct
46 Correct 78 ms 384 KB Output is correct
47 Correct 95 ms 384 KB Output is correct
48 Correct 86 ms 632 KB Output is correct
49 Correct 75 ms 384 KB Output is correct
50 Correct 90 ms 384 KB Output is correct
51 Correct 86 ms 384 KB Output is correct
52 Correct 84 ms 384 KB Output is correct
53 Correct 84 ms 384 KB Output is correct
54 Correct 80 ms 396 KB Output is correct
55 Correct 74 ms 384 KB Output is correct
56 Correct 86 ms 400 KB Output is correct
57 Correct 73 ms 516 KB Output is correct
58 Correct 86 ms 376 KB Output is correct
59 Correct 84 ms 516 KB Output is correct
60 Correct 88 ms 520 KB Output is correct