답안 #965152

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
965152 2024-04-18T07:48:24 Z Darren0724 Ancient Machine 2 (JOI23_ancient2) C++17
0 / 100
157 ms 1116 KB
#include "ancient2.h"
//#include "grader.cpp"
#include<bits/stdc++.h>
using namespace std;
const int lim=1001;
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 Incorrect 157 ms 1116 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -