| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1018548 | vjudge1 | Spirale (COCI18_spirale) | C++17 | 19 ms | 496 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=55;
int const mod=1e9+7;
int n,m,k;
vector<pair<int,int>> clo;
vector<pair<int,int>> ani;
int ans[N][N];
int solve(int x,int y,int r,int c){
r-=x;
c-=y;
if(c>r){//even
int d=max(abs(r),abs(c));
int v=((d*2)-1)*((d*2)-1);
v+=c+r+2*d;
return v;
}
else{//odd
int d=max(abs(r),abs(c));
int v=(d*2)*(d*2);
v+=(d+1)-c;
v+=d-r;
return v;
}
}
int main(){
cin>>n>>m>>k;
for (int i = 0; i < k; ++i)
{
int x,y,t;
cin>>x>>y>>t;
if(t==0)
clo.push_back({x,y});
else
ani.push_back({x,y});
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
ans[i][j]=1e9;
for(auto [x,y]:clo)
ans[i][j]=min(ans[i][j],solve(x,y,i,j));
for(auto [x,y]:ani)
ans[i][j]=min(ans[i][j],solve(x,y,i,(y*2)-j));
cout<<ans[i][j]<<' ';
}
cout<<endl;
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
