竞赛讨论区 > map为什么会超时?
头像
zzzzzzzzzzzyc
发布于 2020-06-11 13:11
+ 关注

map为什么会超时?

我就想问一句话,为啥这题用map会超时?
#include<iostream>
#include<algorithm>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
const int N=4e3+10;
const int inf=0x3f3f3f3f;
const double eps=1e-6;

ll a[N],b[N],c[N],d[N];
map<ll,ll> mp;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%lld%lld%lld%lld",&a[i],&b[i],&c[i],&d[i]);
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            mp[a[i]+b[j]]++;
    sort(pp.begin(),pp.end());
    ll ans=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            ans+=mp[-(c[i]+d[j])];
    printf("%lld\n",ans);
}


全部评论

(0) 回帖
加载中...
话题 回帖

等你来战

查看全部

热门推荐