제출 #378584

#제출 시각아이디문제언어결과실행 시간메모리
378584i_am_noobChessboard (IZhO18_chessboard)C++17
100 / 100
1548 ms4036 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(n) rep1(i,n) #define rep1(i,n) rep2(i,0,n) #define rep2(i,a,b) for(int i=a; i<b; ++i) #define rep3(i,a,b) for(int i=a; i>=b; --i) #define sz(a) ((int)a.size()) #define all(a) a.begin(),a.end() #define pow2(x) (1ll<<(x)) #ifdef i_am_noob #define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__) template<typename T> void _do(T && x){cerr << x << endl;} template<typename T, typename ...S> void _do(T && x, S&&... y){cerr << x << ' ',_do(y...);} #else #define bug(...) 826 #endif const int maxn=100005; const int mod=1000000007; #define y1 hhhhaura_TOI_2J int n,k,x1[maxn],x2[maxn],y1[maxn],y2[maxn],area,ans=1e18; inline int calc(int t, int x, int y){ if(x<0||y<0) return 0; int a=x/t,b=y/t,res=(x/t)*(y/t)/2*t*t; int c=a&1?(b+1)/2*t:b/2*t; c+=y%t+1; int d=b&1?(a+1)/2*t:a/2*t; d+=x%t+1; if(x==2&&y==2) bug(c,d); if((a+b)&1) return res+c*d-(c-y%t-1)*(d-x%t-1); return res+c*d-(c-y%t-1)*(d-x%t-1)-(x%t+1)*(y%t+1); } inline int calc1(int t, int id){ return calc(t,x2[id],y2[id])-calc(t,x1[id]-1,y2[id])-calc(t,x2[id],y1[id]-1)+calc(t,x1[id]-1,y1[id]-1); } inline int calc2(int t, int id){ return (x2[id]-x1[id]+1)*(y2[id]-y1[id]+1)-calc1(t,id); } signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); #ifdef i_am_noob freopen("input1.txt","r",stdin); freopen("output1.txt","w",stdout); freopen("output2.txt","w",stderr); #endif cin >> n >> k; rep(k) cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; rep(k) x1[i]--,y1[i]--,x2[i]--,y2[i]--; rep(k) area+=(x2[i]-x1[i]+1)*(y2[i]-y1[i]+1); rep(5) rep1(j,5){ int tmp=calc(2,i,j); bug(i,j,tmp); } rep2(i,1,n) if(n%i==0){ int val=0; rep1(j,k) val+=calc1(i,j); //area-val good //cnt(black)-(area-val) bug(val); val+=((n/i)&1?((n/i)*(n/i)+1)/2*i*i:(n/i)*(n/i)/2*i*i)-area+val; ans=min(ans,val); bug(val); val=0; rep1(j,k) val+=calc2(i,j); bug(val); val+=(n/i)*(n/i)/2*i*i-area+val; ans=min(ans,val); bug(val); } cout << ans << "\n"; }

컴파일 시 표준 에러 (stderr) 메시지

chessboard.cpp: In function 'long long int calc(long long int, long long int, long long int)':
chessboard.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 | #define bug(...) 826
      |                  ^~~
chessboard.cpp:34:20: note: in expansion of macro 'bug'
   34 |     if(x==2&&y==2) bug(c,d);
      |                    ^~~
chessboard.cpp: In function 'int main()':
chessboard.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 | #define bug(...) 826
      |                  ^~~
chessboard.cpp:60:9: note: in expansion of macro 'bug'
   60 |         bug(i,j,tmp);
      |         ^~~
chessboard.cpp:59:13: warning: unused variable 'tmp' [-Wunused-variable]
   59 |         int tmp=calc(2,i,j);
      |             ^~~
chessboard.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 | #define bug(...) 826
      |                  ^~~
chessboard.cpp:67:9: note: in expansion of macro 'bug'
   67 |         bug(val);
      |         ^~~
chessboard.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 | #define bug(...) 826
      |                  ^~~
chessboard.cpp:70:9: note: in expansion of macro 'bug'
   70 |         bug(val);
      |         ^~~
chessboard.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 | #define bug(...) 826
      |                  ^~~
chessboard.cpp:73:9: note: in expansion of macro 'bug'
   73 |         bug(val);
      |         ^~~
chessboard.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 | #define bug(...) 826
      |                  ^~~
chessboard.cpp:76:9: note: in expansion of macro 'bug'
   76 |         bug(val);
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...