Submission #890843

# Submission time Handle Problem Language Result Execution time Memory
890843 2023-12-22T04:09:23 Z Muhammad_Aneeq Pairs (IOI07_pairs) C++17
45 / 100
4000 ms 28472 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;
}
inline void solve()
{
  long long B,N,D,M;
  cin>>B>>N>>D>>M;
  int a[N][B];
  map<vector<int>,int>d;
  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]);
    d[g]++;
    s.insert(g);
  }
  vector<vector<int>>z={begin(s),end(s)};
  for (int i=0;i<z.size();i++)
  {
    int g=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+=d[z[i]]*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 'void solve()':
pairs.cpp:41: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]
   41 |   for (int i=0;i<z.size();i++)
      |                ~^~~~~~~~~
pairs.cpp:45: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]
   45 |     for (int j=i+1;j<z.size();j++)
      |                    ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1428 KB Output is correct
2 Correct 61 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4061 ms 26964 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4043 ms 26828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 6 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 197 ms 4592 KB Output is correct
2 Execution timed out 4035 ms 4544 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4075 ms 27704 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4018 ms 27644 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 724 KB Output is correct
2 Correct 60 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 2896 KB Output is correct
2 Correct 88 ms 2980 KB Output is correct
3 Correct 117 ms 3652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4010 ms 23260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4029 ms 28472 KB Time limit exceeded
2 Halted 0 ms 0 KB -