제출 #605758

#제출 시각아이디문제언어결과실행 시간메모리
605758ukraineCount Squares (CEOI19_countsquares)C++17
100 / 100
1932 ms211200 KiB
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ins insert
#define setpre(i) setprecision(i) << fixed
#define foru(i,a,b) for(int i = a; i <= b; i++)
#define ford(i,a,b) for(int i = a; i >= b; i--)
using namespace std;

typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<vector<pll> > vvl;
typedef vector<int> vi;
const ll inf = INT_MIN;
const ll mod = 1e9+7;

map<ll, int> cntx;
map<ll, int> cnty;

ll x[1501], y[1501];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    int n,m; cin >> n >> m;
    foru(i,1,n) {
    	cin >> y[i];
    	foru(j,1,i-1) {
    		cnty[y[i]-y[j]]++;
		}
	}
	foru(i,1,m) {
		cin >> x[i];
		foru(j,1,i-1) {
    		cntx[x[i]-x[j]]++;
		}
	}
	ll ans = 0;
	for(auto v : cnty) {
		//cout << v.fi << " " << v.se << " " << cntx[v.fi] << "\n";
		ans += (v.se*cntx[v.fi]);
	}
	cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...