# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
96625 | 2019-02-10T13:37:26 Z | KLPP | Hidden Sequence (info1cup18_hidden) | C++14 | 183 ms | 504 KB |
#include<bits/stdc++.h> #include "grader.h" using namespace std; vector<int> query; bool q(int first, int a, int b){query.clear(); for(int i=0;i<a;i++)query.push_back(first); for(int i=0;i<b;i++)query.push_back(1-first); return isSubsequence(query); } 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); } int maxLength=N/2+1; //cout<<obj<<" "<<zeros<<" "<<ones<<endl; int seq[zeros+1]; for(int i=1;i<=zeros;i++){ int k=zeros+1-i; int m1,m2; for(int j=0;i+j<=maxLength;j++){ if(q(obj,i,j))m1=j; } for(int j=0;k+j<=maxLength;j++){ if(q(1-obj,j,k))m2=j; } if(m1+i==maxLength){ m1=ones-m2; }else{ m2=ones-m1; } //cout<<m1<<" A "<<m2<<endl; seq[i-1]=m2; } seq[zeros]=ones; for(int i=0;i<=zeros;i++){ if(i!=0){ for(int j=0;j<seq[i]-seq[i-1];j++)ans.push_back(1-obj); }else{ for(int j=0;j<seq[i];j++)ans.push_back(1-obj); } if(i!=zeros)ans.push_back(obj); } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 296 KB | Output is correct: Maximum length of a query = 5 |
2 | Correct | 2 ms | 248 KB | Output is correct: Maximum length of a query = 6 |
3 | Correct | 3 ms | 376 KB | Output is correct: Maximum length of a query = 5 |
4 | Correct | 2 ms | 248 KB | Output is correct: Maximum length of a query = 5 |
5 | Correct | 2 ms | 504 KB | Output is correct: Maximum length of a query = 4 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 125 ms | 376 KB | Output is correct: Maximum length of a query = 83 |
2 | Correct | 132 ms | 248 KB | Output is correct: Maximum length of a query = 90 |
3 | Correct | 148 ms | 248 KB | Output is correct: Maximum length of a query = 96 |
4 | Correct | 90 ms | 248 KB | Output is correct: Maximum length of a query = 77 |
5 | Correct | 147 ms | 376 KB | Output is correct: Maximum length of a query = 95 |
6 | Correct | 104 ms | 320 KB | Output is correct: Maximum length of a query = 87 |
7 | Correct | 146 ms | 248 KB | Output is correct: Maximum length of a query = 97 |
8 | Correct | 86 ms | 312 KB | Output is correct: Maximum length of a query = 83 |
9 | Correct | 179 ms | 400 KB | Output is correct: Maximum length of a query = 101 |
10 | Correct | 183 ms | 248 KB | Output is correct: Maximum length of a query = 100 |
11 | Correct | 75 ms | 316 KB | Output is correct: Maximum length of a query = 96 |
12 | Correct | 136 ms | 248 KB | Output is correct: Maximum length of a query = 100 |
13 | Correct | 149 ms | 248 KB | Output is correct: Maximum length of a query = 101 |