# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
912861 | 2024-01-20T03:14:20 Z | Faisal_Saqib | 이상적인 도시 (IOI12_city) | C++17 | 1000 ms | 856 KB |
#pragma once #include <vector> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <iostream> #include <cmath> #include <queue> using namespace std; /* 1 11 N <= 2e2 O(n^2) 2 21 N <= 2e3 O(n^2) 3 23 N <= 1e5 4 45 N <= 1e5 For 3 any two cell such x[i]<=x[j] then for all x such that x[i]<=x<=x[j] there is non empty cell there */ const int N=2001; vector<int> ma[N]; bool vis[N]; int h[N]; int DistanceSum(int n, int x[], int y[]) { if(n<=2000) { for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { if((abs(x[i]-x[j])+abs(y[i]-y[j]))==1) { ma[i].push_back(j); ma[j].push_back(i); } } } long long ans1=0; long long mod=1e9; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { h[j]=0; vis[j]=0; } queue<int> q; q.push(i); vis[i]=1; long long ans=0; while(q.size()) { int x=q.front(); ans+=(long long)h[x]; q.pop(); for(int y:ma[x]) { if(!vis[y]) { vis[y]=1; h[y]=h[x]+1; q.push(y); } } } ans1+=ans; } ans1/=2; return ans1%mod; } long long other=0; long long mod=1e9; for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { other+=(abs(x[i]-x[j])+abs(y[i]-y[j])); other%=mod; } } return other%mod; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 476 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 604 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 348 KB | Output is correct |
2 | Correct | 19 ms | 532 KB | Output is correct |
3 | Correct | 40 ms | 536 KB | Output is correct |
4 | Correct | 46 ms | 600 KB | Output is correct |
5 | Correct | 73 ms | 344 KB | Output is correct |
6 | Correct | 80 ms | 344 KB | Output is correct |
7 | Correct | 77 ms | 348 KB | Output is correct |
8 | Correct | 83 ms | 348 KB | Output is correct |
9 | Correct | 86 ms | 560 KB | Output is correct |
10 | Correct | 76 ms | 564 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 677 ms | 680 KB | Output is correct |
2 | Correct | 674 ms | 680 KB | Output is correct |
3 | Execution timed out | 1020 ms | 856 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 674 ms | 604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |