제출 #128725

#제출 시각아이디문제언어결과실행 시간메모리
128725E869120Binary Subsequences (info1cup17_binary)C++14
0 / 100
66 ms376 KiB
#include <iostream> #include <algorithm> #include <vector> using namespace std; #pragma warning (disable: 4996) int len[250], mask[250]; void hantei(int dig, int masks) { vector<int>P[20]; for (int i = 0; i < dig; i++) { int s = 0; for (int j = i; j < dig; j++) { // 区間 [i, j] s += (1 << j); P[j - i].push_back((masks&s) >> i); } } int cnt = 0; for (int i = 0; i < dig; i++) { sort(P[i].begin(), P[i].end()); P[i].erase(unique(P[i].begin(), P[i].end()), P[i].end()); cnt += P[i].size(); } if (len[cnt] > dig) { len[cnt] = dig; mask[cnt] = masks; } } void init() { for (int i = 0; i < 250; i++) { len[i] = (1 << 30); mask[i] = -1; } for (int i = 1; i <= 13; i++) { for (int j = 0; j < (1 << i); j++) hantei(i, j); } } void solve(int A) { if (A >= 250 || len[A] == (1 << 30)) { cout << "-1" << endl; cout << "-1" << endl; } else { cout << len[A] << endl; for (int i = 0; i < len[A]; i++) { if (i) cout << " "; cout << (mask[A] / (1 << i)) % 2; } cout << endl; } } int main() { init(); int T; scanf("%d", &T); for (int i = 1; i <= T; i++) { int K; scanf("%d", &K); solve(K); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

binary.cpp:5:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning (disable: 4996)
 
binary.cpp: In function 'int main()':
binary.cpp:58:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int T; scanf("%d", &T);
         ~~~~~^~~~~~~~~~
binary.cpp:60:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int K; scanf("%d", &K);
          ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...