Submission #267302

#TimeUsernameProblemLanguageResultExecution timeMemory
267302taulantCount Squares (CEOI19_countsquares)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; int main(){ cin.tie(0)->sync_with_stdio(0); int h, v; cin >> h >> v; map<int, int> m, n; vector<int> v(h), w(v); for(int& i:v) cin >> i; for(int& i:w) cin >> i; for(int i=0; i<h; ++i) for(int j=i+1; j<h; ++j) ++m[v[j]-v[i]]; for(int i=0; i<v; ++i) for(int j=i+1; j<v; ++j) ++n[w[j]-w[i]]; int ans = 0; for(auto& i:m) ans += i.second * n[i.first]; cout << ans << endl; }

Compilation message (stderr)

countsquares.cpp: In function 'int main()':
countsquares.cpp:8:14: error: conflicting declaration 'std::vector<int> v'
    8 |  vector<int> v(h), w(v);
      |              ^
countsquares.cpp:6:9: note: previous declaration as 'int v'
    6 |  int h, v; cin >> h >> v;
      |         ^
countsquares.cpp:9:13: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
    9 |  for(int& i:v) cin >> i;
      |             ^
      |             std::begin
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from countsquares.cpp:1:
/usr/include/c++/9/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
countsquares.cpp:9:13: error: 'end' was not declared in this scope; did you mean 'std::end'?
    9 |  for(int& i:v) cin >> i;
      |             ^
      |             std::end
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from countsquares.cpp:1:
/usr/include/c++/9/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
countsquares.cpp:11:57: error: invalid types 'int[int]' for array subscript
   11 |  for(int i=0; i<h; ++i) for(int j=i+1; j<h; ++j) ++m[v[j]-v[i]];
      |                                                         ^
countsquares.cpp:11:62: error: invalid types 'int[int]' for array subscript
   11 |  for(int i=0; i<h; ++i) for(int j=i+1; j<h; ++j) ++m[v[j]-v[i]];
      |                                                              ^