Submission #67146

#TimeUsernameProblemLanguageResultExecution timeMemory
67146MrTEKHidden Sequence (info1cup18_hidden)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "grader.h" using namespace std; #define mp make_pair #define pb push_back #define len(a) (int)a.size() #define fi first #define sc second #define d1(w) cerr<<#w<<":"<<w<<endl; #define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl; #define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl; #define left ind+ind #define right ind+ind+1 #define mid (l+r)/2 #define FAST_IO ios_base::sync_with_stdio(false); #define endl '\n' const int maxn = 620; const long long LINF = 1e18; const int LOG = 31; const int INF = 1e9; const int N = 1e3 + 5; const int M = 4; const int SQ = 350; const int MOD = 998244353; using namespace std; static int maxQ = 0; static vector < int > theRealAnswer; bool isSubsequence (vector < int > v) { if (v.size () > maxQ) maxQ = v.size (); int i = 0; for (auto it : v) { while (i < theRealAnswer.size () && it != theRealAnswer[i]) i ++; if (i == theRealAnswer.size ()) return 0; i ++; } return 1; } vector < int > findSequence (int N) { vector < int > ans (N, 0),sif,v; for (int i = 0 ; i < N ; i++) { sif.pb(0); if (isSubsequence(sif) == false) {sif.pop_back();break;} } if (len(sif) == N) { for (int i = 0 ; i < N ; i++) ans[i] = sif[i]; return ans; } else if(len(sif) == 0) { for (int i = 0 ; i < N ; i++) ans[i] = 1; return ans; } for (int i = 0 ; i < N ; i++) { v.clear(); for (int j = 0; j < i ; j++) v.pb(ans[j]); v.pb(1); for (int j = 0 ; j < len(sif) ; j++) v.pb(sif[j]); if (len(v) > N) { for (int j = i ; j < N ; j++) ans[i] = 0; break; } // printf("%d ------>",i + 1); // for (auto j : v) printf("%d ",j); // puts(""); if (isSubsequence(v)) { ans[i] = 1; continue; } else { ans[i] = 0; sif.pop_back(); } } return ans; } int main () { int n, x; scanf ("%d", &n), maxQ = 0; for (int i=1; i<=n; i++) scanf ("%d", &x), theRealAnswer.push_back (x); vector < int > ans = findSequence (n); if (ans.size () != theRealAnswer.size ()) { printf ("Different lengths\n"); for (auto it : ans) printf ("%d ", it); printf ("\n"); return 0; } for (int i=0; i<ans.size (); i++) if (ans[i] != theRealAnswer[i]) { printf ("WA position %d\n", i + 1); for (auto it : ans) printf ("%d ", it); printf ("\n"); return 0; } printf ("Ok, biggest queried length %d\n", maxQ); return 0; }

Compilation message (stderr)

hidden.cpp: In function 'bool isSubsequence(std::vector<int>)':
hidden.cpp:35:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (v.size () > maxQ)
         ~~~~~~~~~~^~~~~~
hidden.cpp:40:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (i < theRealAnswer.size () && it != theRealAnswer[i]) i ++;
                ~~^~~~~~~~~~~~~~~~~~~~~~~
hidden.cpp:41:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (i == theRealAnswer.size ()) return 0;
             ~~^~~~~~~~~~~~~~~~~~~~~~~~
hidden.cpp: In function 'int main()':
hidden.cpp:101:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for (int i=0; i<ans.size (); i++)
               ~^~~~~~~~~~~~
hidden.cpp:87:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d", &n), maxQ = 0;
 ~~~~~~~~~~~~~~~~^~~~~~~~~~
hidden.cpp:89:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d", &x), theRealAnswer.push_back (x);
     ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
grader.cpp: In function 'int main()':
grader.cpp:28:43: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     fprintf (fifo_out, "%d\n", ans.size ());
                                ~~~~~~~~~~~^
grader.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<ans.size () && i < N; i++)
                   ~^~~~~~~~~~~~
/tmp/ccjWlqdR.o: In function `isSubsequence(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x0): multiple definition of `isSubsequence(std::vector<int, std::allocator<int> >)'
/tmp/ccZ1nlZQ.o:hidden.cpp:(.text+0x0): first defined here
/tmp/ccjWlqdR.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccZ1nlZQ.o:hidden.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status