답안 #267302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
267302 2020-08-16T03:10:49 Z taulant Count Squares (CEOI19_countsquares) C++14
컴파일 오류
0 ms 0 KB
#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

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]];
      |                                                              ^