답안 #855561

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
855561 2023-10-01T12:28:53 Z tvladm2009 Count Squares (CEOI19_countsquares) C++17
100 / 100
1379 ms 158856 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int N = 1500 + 7;
int x[N], y[N];

int main() {
#ifdef ONPC
  freopen("input.txt", "r", stdin);
#else
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif // ONPC

  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> y[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> x[i];
  }
  map<int, int> cntY, cntX;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      cntY[y[i] - y[j]]++;
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j < i; j++) {
      cntX[x[i] - x[j]]++;
    }
  }
  ll sol = 0;
  for (auto &it : cntY) {
    sol += (ll) cntY[it.first] * cntX[it.first];
  }
  cout << sol << "\n";
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 132 ms 25572 KB Output is correct
7 Correct 136 ms 25692 KB Output is correct
8 Correct 130 ms 25592 KB Output is correct
9 Correct 127 ms 24916 KB Output is correct
10 Correct 7 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 132 ms 25572 KB Output is correct
7 Correct 136 ms 25692 KB Output is correct
8 Correct 130 ms 25592 KB Output is correct
9 Correct 127 ms 24916 KB Output is correct
10 Correct 7 ms 856 KB Output is correct
11 Correct 1379 ms 158856 KB Output is correct
12 Correct 1346 ms 158548 KB Output is correct
13 Correct 1339 ms 158392 KB Output is correct
14 Correct 1310 ms 156616 KB Output is correct
15 Correct 70 ms 1620 KB Output is correct