답안 #891044

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891044 2023-12-22T06:48:02 Z Muhammad_Aneeq Pairs (IOI07_pairs) C++17
18 / 100
4000 ms 520272 KB
/*
بسم الله الرحمن الرحيم
Author:
                          (:Muhammad Aneeq:)
*/
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
#define int long long
int dis(vector<int>&a,vector<int>&b)
{
  int z=0;
  for (int j=0;j<b.size();j++)
    z+=abs(a[j]-b[j]);
  return z;
}
int const N=75e6+10;
int cnt[N]={};
int d(vector<int>&a)
{
  int z=0;
  for (int i=0;i<a.size();i++)
    z=z*7+a[i];
  return z;
}
inline void solve()
{
  long long B,N,D,M;
  cin>>B>>N>>D>>M;
  int a[N][B];
  for (int i=0;i<N;i++)
  {
    for (int j=0;j<B;j++)
      cin>>a[i][j];
  }
  int ans=0;
  set<vector<int>>s;
  for (int i=0;i<N;i++)
  {
    vector<int>g;
    for (int j=0;j<B;j++)
      g.push_back(a[i][j]);
    cnt[d(g)]++;
    s.insert(g);
  }
  vector<vector<int>>z={begin(s),end(s)};
  for (int i=0;i<z.size();i++)
  {
    int g=cnt[d(z[i])];
    ans+=(g*(g-1))/2;
    for (int j=i+1;j<z.size();j++)
    {
      int di=dis(z[i],z[j]);
      if (di<=D)
        ans+=cnt[d(z[i])]*cnt[d(z[j])];
    }
  }
  cout<<ans<<endl;
}
signed main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        solve();
}

Compilation message

pairs.cpp: In function 'long long int dis(std::vector<long long int>&, std::vector<long long int>&)':
pairs.cpp:15:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for (int j=0;j<b.size();j++)
      |                ~^~~~~~~~~
pairs.cpp: In function 'long long int d(std::vector<long long int>&)':
pairs.cpp:24:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for (int i=0;i<a.size();i++)
      |                ~^~~~~~~~~
pairs.cpp: In function 'void solve()':
pairs.cpp:49:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for (int i=0;i<z.size();i++)
      |                ~^~~~~~~~~
pairs.cpp:53:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (int j=i+1;j<z.size();j++)
      |                    ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 293972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1628 KB Output is correct
2 Correct 16 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4062 ms 440876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4029 ms 520272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 153 ms 3924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4051 ms 17488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4014 ms 24144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 3420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4045 ms 15384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4091 ms 18320 KB Time limit exceeded
2 Halted 0 ms 0 KB -