답안 #974535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974535 2024-05-03T12:30:09 Z LCJLY Hidden Sequence (info1cup18_hidden) C++14
87 / 100
4 ms 696 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

//code
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<long long,long long>pii;
typedef pair<int,pii>pi2;
//isSubsequence()
vector<int> findSequence(int n){
	int half=n/2;
	vector<int>v;
	for(int x=0;x<half+1;x++){
		v.push_back(0);
	}
	
	bool hold=isSubsequence(v);
	int flip=0;
	if(hold){
		flip=1;
	}
	
	//flip = 1 means 1 is minority
	//flip = 0 means 0 is minority
	
	v.clear();
	while(isSubsequence(v)){
		v.push_back(0^flip);
	}
	v.pop_back();
	
	//zero is the minority
	vector<int>ans;
	int cnt=v.size();
	int l=0; //cnt zero to the left
	//show(flip,flip);
	for(int x=0;x<n;x++){
		//put 1
		vector<int>temp;
		for(int y=0;y<x-l;y++){
			temp.push_back(1^flip);
		}
		temp.push_back(1^flip);
		for(int y=0;y<cnt;y++){
			temp.push_back(0^flip);
		}
		 
		//put 0
		vector<int>temp2;
		for(int y=0;y<l;y++){
			temp2.push_back(0^flip);
		}
		temp2.push_back(0^flip);
		//show(n-x-cnt+1,n-x-cnt+1);
		for(int y=0;y<n-x-cnt;y++){
			temp2.push_back(1^flip);
		}
		
		//show(x,x);
		//show4(temp,temp);
		//show4(temp2,temp2);

		if((int)temp.size()<=half+3){
			bool amos=isSubsequence(temp);
			if(amos){
				ans.push_back(1^flip);	
			}
			else{
				ans.push_back(0^flip);
				cnt--;
				l++;
			}
		}
		else{
			bool amos=isSubsequence(temp2);
			if(amos){
				ans.push_back(0^flip);
				cnt--;
				l++;
			}
			else{
				ans.push_back(1^flip);
			}
		}
	}
	return ans;
}

//code

Compilation message

grader.cpp: In function 'int main()':
grader.cpp:28:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   28 |     fprintf (fifo_out, "%d\n", ans.size ());
      |                         ~^     ~~~~~~~~~~~
      |                          |              |
      |                          int            std::vector<int>::size_type {aka long unsigned int}
      |                         %ld
grader.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i=0; i<ans.size () && i < N; i++)
      |                   ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 6
2 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 8
3 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 6
4 Correct 0 ms 344 KB Output is correct: Maximum length of a query = 5
5 Partially correct 0 ms 344 KB Output is partially correct: Maximum length of a query = 6
# 결과 실행 시간 메모리 Grader output
1 Partially correct 3 ms 440 KB Output is partially correct: Maximum length of a query = 85
2 Partially correct 3 ms 684 KB Output is partially correct: Maximum length of a query = 92
3 Partially correct 3 ms 432 KB Output is partially correct: Maximum length of a query = 98
4 Partially correct 2 ms 696 KB Output is partially correct: Maximum length of a query = 79
5 Partially correct 3 ms 440 KB Output is partially correct: Maximum length of a query = 97
6 Partially correct 3 ms 344 KB Output is partially correct: Maximum length of a query = 89
7 Partially correct 3 ms 692 KB Output is partially correct: Maximum length of a query = 99
8 Partially correct 3 ms 440 KB Output is partially correct: Maximum length of a query = 85
9 Partially correct 3 ms 696 KB Output is partially correct: Maximum length of a query = 103
10 Partially correct 3 ms 692 KB Output is partially correct: Maximum length of a query = 102
11 Correct 3 ms 436 KB Output is correct: Maximum length of a query = 96
12 Partially correct 3 ms 688 KB Output is partially correct: Maximum length of a query = 102
13 Partially correct 4 ms 692 KB Output is partially correct: Maximum length of a query = 103