Submission #128731

#TimeUsernameProblemLanguageResultExecution timeMemory
128731E869120Binary Subsequences (info1cup17_binary)C++14
0 / 100
277 ms384 KiB
#include <iostream> #include <algorithm> #include <vector> using namespace std; #pragma warning (disable: 4996) int len[250], mask[250], num[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; num[cnt] = 1; } else if (len[cnt] == dig) { num[cnt]++; } } void init() { for (int i = 0; i < 250; i++) { len[i] = (1 << 30); mask[i] = -1; } for (int i = 1; i <= 15; 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 << "-1" << 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; }

Compilation message (stderr)

binary.cpp:5:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning (disable: 4996)
 
binary.cpp: In function 'int main()':
binary.cpp:62: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:64: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...