Submission #416316

#TimeUsernameProblemLanguageResultExecution timeMemory
416316Runtime_error_Count Squares (CEOI19_countsquares)C++14
100 / 100
3039 ms211288 KiB

#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...