# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890853 | 2023-12-22T04:19:11 Z | Muhammad_Aneeq | Pairs (IOI07_pairs) | C++17 | 4000 ms | 524288 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*26+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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 133 ms | 524092 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 1372 KB | Output is correct |
2 | Correct | 17 ms | 1368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 68 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 64 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 16984 KB | Output is correct |
2 | Correct | 4 ms | 16988 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 140 ms | 3528 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4035 ms | 19028 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4019 ms | 33232 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 2652 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 2948 KB | Output is correct |
2 | Correct | 31 ms | 2944 KB | Output is correct |
3 | Correct | 30 ms | 2948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4041 ms | 16716 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4058 ms | 19796 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |