Submission #416316

# Submission time Handle Problem Language Result Execution time Memory
416316 2021-06-02T10:16:56 Z Runtime_error_ Count Squares (CEOI19_countsquares) C++14
100 / 100
3039 ms 211288 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf = 1509;
ll n,m,ans,h[inf],v[inf];
map<ll,ll> LengthV,LengthH;

int main(){
    scanf("%lld%lld",&n,&m);
    for(ll i=1;i<=n;i++){
        scanf("%lld",h+i);
        for(ll j=1;j<i;j++)
            LengthH[ h[i]-h[j] ]++;
    }
    for(ll i=1;i<=m;i++){
        scanf("%lld",v+i);
        for(ll j=1;j<i;j++)
            LengthV[v[i]-v[j]]++;
    }
    for(auto o:LengthH)
        ans += o.second * LengthV[o.first];
    printf("%lld\n",ans);
}
/*
4
1 4 2 5
6
3 6 4 5 1 2
*/

Compilation message

countsquares.cpp: In function 'int main()':
countsquares.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
countsquares.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%lld",h+i);
      |         ~~~~~^~~~~~~~~~~~
countsquares.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld",v+i);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 361 ms 33928 KB Output is correct
7 Correct 300 ms 33860 KB Output is correct
8 Correct 334 ms 33960 KB Output is correct
9 Correct 307 ms 33052 KB Output is correct
10 Correct 12 ms 948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 361 ms 33928 KB Output is correct
7 Correct 300 ms 33860 KB Output is correct
8 Correct 334 ms 33960 KB Output is correct
9 Correct 307 ms 33052 KB Output is correct
10 Correct 12 ms 948 KB Output is correct
11 Correct 3039 ms 211284 KB Output is correct
12 Correct 2825 ms 211100 KB Output is correct
13 Correct 2778 ms 211288 KB Output is correct
14 Correct 2470 ms 208644 KB Output is correct
15 Correct 88 ms 1860 KB Output is correct