# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
91265 | Vardanyan | Chessboard (IZhO18_chessboard) | C++14 | 353 ms | 48872 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 1000*100+5;
long long tox_type[N];
long long pref_type1[N];
long long pref_type2[N];
int X1[N],X2[N],Y1[N],Y2[N];
long long syun_pref_type[N];
int main()
{
int n,k;
scanf("%d%d",&n,&k);
for(int i = 1;i<=k;i++) scanf("%d%d%d%d",&X1[i],&Y1[i],&X2[i],&Y2[i]);
long long ans = 100000000000000005;
for(int w = 1;w<=n/2;w++){
if(n%w) continue;
memset(tox_type,0,sizeof tox_type);
memset(pref_type1,0,sizeof pref_type1);
memset(pref_type2,0,sizeof pref_type2);
memset(syun_pref_type,0,sizeof syun_pref_type);
for(int j = 1;j<=n;j++){
int x = (j-1)/w;
if(x%2 == 0){
// sev
tox_type[j] = 1;
syun_pref_type[j] = syun_pref_type[j-1]+1;
}
else{
// spitak
tox_type[j] = 2;
syun_pref_type[j] = syun_pref_type[j-1];
}
}
for(int j = 1;j<=n;j++){
int x = (j-1)/w;
if(x%2 == 0){
pref_type1[j] = pref_type1[j-1]+1;
pref_type2[j] = pref_type2[j-1];
}
else{
pref_type1[j] = pref_type1[j-1];
pref_type2[j] = pref_type2[j-1]+1;
}
}
long long need = 0;
long long need2 = 0;
for(int i = 1;i<=n;i++){
if(tox_type[i] == 1) need+=pref_type1[n];
else need+=pref_type2[n];
}
need2 = n;
need2*=n;
need2-=need;
for(int i = 1;i<=k;i++){
long long x1 = X1[i],y1 = Y1[i];
long long x2 = X2[i],y2 = Y2[i];
long long qan_tp1 = syun_pref_type[x2]-syun_pref_type[x1-1];
long long qan_tp2 = (x2-x1+1)-qan_tp1;
long long sev = (qan_tp1*(pref_type1[y2]-pref_type1[y1-1])+qan_tp2*(pref_type2[y2]-pref_type2[y1-1]));
need-=sev;
need+=((x2-x1+1)*(y2-y1+1)-sev);
need2-=((x2-x1+1)*(y2-y1+1)-sev);
need2+=sev;
}
ans = min(ans,min(need,need2));
}
cout<<ans<<endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |