제출 #306571

#제출 시각아이디문제언어결과실행 시간메모리
306571peti1234Painting Squares (IOI20_squares)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "squares.h" using namespace std; const int c=512; int n; vector<int> sol, s, ans, sz[c]; bool v[c][2]; void dfs(int a) { if (!v[a][0]) { v[a][0]=1, dfs(sz[a][0]); s.push_back(0); } if (!v[a][1]) { v[a][1]=1, dfs(sz[a][1]); s.push_back(1); } } vector<int> paint(int N) { n=N; for (int i=0; i<c; i++) sz[i].clear(), sol.clear(), s.clear(), ans.clear(), v[i][0]=0, v[i][1]=0; for (int i=0; i<c; i++) { int x=2*i%c; sz[i].push_back(x), sz[i].push_back(x+1); } dfs(0); for (int i=0; i<9; i++) sol.push_back(0); while(s.size()>0) sol.push_back(s.back()), s.pop_back(); for (int i=0; i<n; i++) ans.push_back(sol[i]); ans.push_back(min(10, n)); for (int i=0; i<10; i++) sol.push_back(-1); for (int i=n; i<n+10; i++) sol[i]=-1; return ans; } int find_location(int n, vector<int> kerd) { int k=kerd.size(); for (int i=0; i<c; i++) sz[i].clear(), sol.clear(), s.clear(), ans.clear(), v[i][0]=0, v[i][1]=0; for (int i=0; i<c; i++) { int x=2*i%c; sz[i].push_back(x), sz[i].push_back(x+1); } dfs(0); for (int i=0; i<9; i++) sol.push_back(0); while(s.size()>0) sol.push_back(s.back()), s.pop_back(); for (int i=0; i<n; i++) ans.push_back(sol[i]); ans.push_back(min(10, n)); for (int i=0; i<10; i++) sol.push_back(-1); for (int i=n; i<n+10; i++) sol[i]=-1; for (int i=0; i<n; i++) { bool jo=1; for (int j=0; j<k; j++) { if (sol[i+j]!=kerd[j]) jo=0; } if (jo) return i; } return n; } int b1, b2, b3, w; vector<int> v1, v2; int main() { cin >> w; while(w--) { cin >> b1; v1=paint(b1); for (int i=0; i<v1.size(); i++) cout << v1[i] << " "; b3=v1.back(); cout << "\n"; cin >> b2; for (int i=0; i<b2; i++) { v2.clear(); for (int i=0; i<b3; i++) { int x; cin >> x; v2.push_back(x); } cout << find_location(b1, v2) << "\n"; } } return 0; }

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

squares.cpp: In function 'int main()':
squares.cpp:65:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for (int i=0; i<v1.size(); i++) cout << v1[i] << " ";
      |                       ~^~~~~~~~~~
/usr/bin/ld: /tmp/ccwiSxc4.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccnU2ua4.o:squares.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status