답안 #965127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
965127 2024-04-18T07:27:18 Z Darren0724 Ancient Machine 2 (JOI23_ancient2) C++17
10 / 100
29 ms 1536 KB
#include "ancient2.h"
//#include "grader.cpp"
#include<bits/stdc++.h>
using namespace std;
const int lim=1002;
string Solve(int N) {
	string ans;
	while(ans.size()<N){
		vector<int> a,b;
		int sz=ans.size();
		for(int i=0;i<sz;i++){
			a.push_back(i+1);
			b.push_back(i+1);
		}
		int last=-1;
		int st=sz+1;
		int p=1;
		int bit=0;
		while(sz+bit<N&&st+p*2-1<lim){
			for(int i=0;i<p;i++){
				a.push_back(st++);
				b.push_back(st++);
			}
			bit++;
			last=st;
			p<<=1;
			//cout<<bit<<' '<<st<<' '<<p<<' '<<lim<<endl;
		}
		while(a.size()<lim){
			a.push_back(a.size());
			b.push_back(b.size());
		}
		int r=Query(lim,a,b);
		r-=sz;
		string t;
		for(int i=0;i<bit;i++){
			if(r&1){
				t.push_back('0');
			}
			else{
				t.push_back('1');
			}
			r=(r-1)/2;
		}
		reverse(t.begin(),t.end());
		ans+=t;
	}
	//cout<<ans<<endl;
	

  	return ans;
}

Compilation message

ancient2.cpp: In function 'std::string Solve(int)':
ancient2.cpp:8:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    8 |  while(ans.size()<N){
      |        ~~~~~~~~~~^~
ancient2.cpp:15:7: warning: variable 'last' set but not used [-Wunused-but-set-variable]
   15 |   int last=-1;
      |       ^~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 21 ms 840 KB Output is partially correct
2 Partially correct 26 ms 1088 KB Output is partially correct
3 Partially correct 22 ms 676 KB Output is partially correct
4 Partially correct 27 ms 1192 KB Output is partially correct
5 Partially correct 24 ms 1032 KB Output is partially correct
6 Partially correct 21 ms 652 KB Output is partially correct
7 Partially correct 22 ms 884 KB Output is partially correct
8 Partially correct 22 ms 892 KB Output is partially correct
9 Partially correct 23 ms 676 KB Output is partially correct
10 Partially correct 21 ms 872 KB Output is partially correct
11 Partially correct 21 ms 684 KB Output is partially correct
12 Partially correct 23 ms 852 KB Output is partially correct
13 Partially correct 22 ms 812 KB Output is partially correct
14 Partially correct 27 ms 848 KB Output is partially correct
15 Partially correct 21 ms 1076 KB Output is partially correct
16 Partially correct 24 ms 900 KB Output is partially correct
17 Partially correct 24 ms 944 KB Output is partially correct
18 Partially correct 22 ms 732 KB Output is partially correct
19 Partially correct 22 ms 668 KB Output is partially correct
20 Partially correct 23 ms 904 KB Output is partially correct
21 Partially correct 25 ms 708 KB Output is partially correct
22 Partially correct 22 ms 564 KB Output is partially correct
23 Partially correct 26 ms 1040 KB Output is partially correct
24 Partially correct 23 ms 788 KB Output is partially correct
25 Partially correct 26 ms 884 KB Output is partially correct
26 Partially correct 23 ms 1100 KB Output is partially correct
27 Partially correct 23 ms 1536 KB Output is partially correct
28 Partially correct 26 ms 664 KB Output is partially correct
29 Partially correct 21 ms 1044 KB Output is partially correct
30 Partially correct 26 ms 456 KB Output is partially correct
31 Partially correct 23 ms 1160 KB Output is partially correct
32 Partially correct 25 ms 688 KB Output is partially correct
33 Partially correct 29 ms 1232 KB Output is partially correct
34 Partially correct 22 ms 660 KB Output is partially correct
35 Partially correct 24 ms 956 KB Output is partially correct
36 Partially correct 23 ms 844 KB Output is partially correct
37 Partially correct 23 ms 1100 KB Output is partially correct
38 Partially correct 22 ms 476 KB Output is partially correct
39 Partially correct 21 ms 904 KB Output is partially correct
40 Partially correct 22 ms 804 KB Output is partially correct
41 Partially correct 23 ms 760 KB Output is partially correct
42 Partially correct 25 ms 1168 KB Output is partially correct
43 Partially correct 22 ms 1060 KB Output is partially correct
44 Partially correct 23 ms 756 KB Output is partially correct
45 Partially correct 25 ms 1184 KB Output is partially correct
46 Partially correct 23 ms 1416 KB Output is partially correct
47 Partially correct 21 ms 1060 KB Output is partially correct
48 Partially correct 23 ms 680 KB Output is partially correct
49 Partially correct 22 ms 892 KB Output is partially correct
50 Partially correct 27 ms 1428 KB Output is partially correct
51 Partially correct 24 ms 1144 KB Output is partially correct
52 Partially correct 21 ms 828 KB Output is partially correct
53 Partially correct 21 ms 528 KB Output is partially correct
54 Partially correct 23 ms 976 KB Output is partially correct
55 Partially correct 22 ms 664 KB Output is partially correct
56 Partially correct 21 ms 928 KB Output is partially correct
57 Partially correct 25 ms 992 KB Output is partially correct
58 Partially correct 24 ms 708 KB Output is partially correct
59 Partially correct 22 ms 928 KB Output is partially correct
60 Partially correct 22 ms 1188 KB Output is partially correct
61 Partially correct 25 ms 876 KB Output is partially correct
62 Partially correct 22 ms 896 KB Output is partially correct
63 Partially correct 23 ms 1040 KB Output is partially correct