# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
96480 | 2019-02-09T15:55:09 Z | KLPP | Hidden Sequence (info1cup18_hidden) | C++14 | 9 ms | 396 KB |
#include<bits/stdc++.h> #include "grader.h" using namespace std; vector < int > findSequence (int N) { int zeros,ones; zeros=-1; ones=-1; for(int i=1;i<=N/2+1;i++){ vector<int> query(i); for(int j=0;j<i;j++)query[j]=0; if(!isSubsequence(query)){ zeros=i-1; i=N/2+1; } } if(zeros!=-1)ones=N-zeros; for(int i=1;i<=N/2+1;i++){ vector<int> query(i); for(int j=0;j<i;j++)query[j]=1; if(!isSubsequence(query)){ ones=i-1; i=N/2+1; } } if(ones!=-1)zeros=N-ones; vector<int> ans; if(zeros==0){ for(int i=0;i<N;i++)ans.push_back(1); return ans; } if(ones==0){ for(int i=0;i<N;i++)ans.push_back(0); return ans; } vector<int> query; int obj=0; if(zeros>=ones){ obj=1; swap(ones,zeros); } //cout<<obj<<" "<<zeros<<" "<<ones<<endl; int ones_pos[zeros+1]; for(int i=0;i<=zeros;i++){ ones_pos[i]=-1; for(int j=1;j<=(ones+1)/2;j++){ for(int k=0;k<=zeros;k++){ if(k==i){ for(int l=0;l<j;l++)query.push_back(1-obj); } if(k!=zeros)query.push_back(obj); } //cout<<"I"<<i<<endl; //for(int test=0;test<query.size();test++)cout<<query[test]<<" "; //cout<<endl; if(!isSubsequence(query)){ ones_pos[i]=j-1; j=N; } query.clear(); } //cout<<ones_pos[i]<<endl; }//cout<<endl; int minus_one=0; for(int i=0;i<=zeros;i++){ if(ones_pos[i]==-1)minus_one++; } if(minus_one==1){ int sum=0; for(int i=0;i<=zeros;i++){ if(ones_pos[i]!=-1)sum+=ones_pos[i]; } for(int i=0;i<=zeros;i++){ if(ones_pos[i]==-1)ones_pos[i]=ones-sum; } }else{ for(int i=0;i<=zeros;i++){ if(ones_pos[i]==-1)ones_pos[i]=ones/2; } } /*for(int i=0;i<=zeros;i++){ cout<<ones_pos[i]<<" "; }cout<<endl;*/ for(int i=0;i<=zeros;i++){ for(int j=0;j<ones_pos[i];j++)ans.push_back(1-obj); if(i!=zeros)ans.push_back(obj); } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 2 ms | 248 KB | Output is partially correct: Maximum length of a query = 6 |
2 | Partially correct | 2 ms | 376 KB | Output is partially correct: Maximum length of a query = 8 |
3 | Partially correct | 2 ms | 376 KB | Output is partially correct: Maximum length of a query = 6 |
4 | Partially correct | 2 ms | 248 KB | Output is partially correct: Maximum length of a query = 7 |
5 | Partially correct | 2 ms | 248 KB | Output is partially correct: Maximum length of a query = 5 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 7 ms | 248 KB | Output is partially correct: Maximum length of a query = 86 |
2 | Partially correct | 4 ms | 396 KB | Output is partially correct: Maximum length of a query = 92 |
3 | Partially correct | 9 ms | 248 KB | Output is partially correct: Maximum length of a query = 102 |
4 | Partially correct | 5 ms | 320 KB | Output is partially correct: Maximum length of a query = 87 |
5 | Partially correct | 9 ms | 376 KB | Output is partially correct: Maximum length of a query = 102 |
6 | Partially correct | 4 ms | 316 KB | Output is partially correct: Maximum length of a query = 129 |
7 | Partially correct | 8 ms | 248 KB | Output is partially correct: Maximum length of a query = 144 |
8 | Partially correct | 4 ms | 312 KB | Output is partially correct: Maximum length of a query = 97 |
9 | Partially correct | 8 ms | 248 KB | Output is partially correct: Maximum length of a query = 114 |
10 | Partially correct | 9 ms | 252 KB | Output is partially correct: Maximum length of a query = 125 |
11 | Partially correct | 8 ms | 376 KB | Output is partially correct: Maximum length of a query = 97 |
12 | Partially correct | 8 ms | 248 KB | Output is partially correct: Maximum length of a query = 149 |
13 | Partially correct | 9 ms | 380 KB | Output is partially correct: Maximum length of a query = 106 |