Submission #378522

#TimeUsernameProblemLanguageResultExecution timeMemory
378522i_am_noobChessboard (IZhO18_chessboard)C++17
70 / 100
374 ms4332 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; int calc1(int t, int id){ return ((x1[id]/t)+(y1[id]/t))&1; } int calc2(int t, int id){ return !(((x1[id]/t)+(y1[id]/t))&1); } 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); bug(area); 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"; }

Compilation message (stderr)

chessboard.cpp: In function 'int main()':
chessboard.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 | #define bug(...) 826
      |                  ^~~
chessboard.cpp:46:5: note: in expansion of macro 'bug'
   46 |     bug(area);
      |     ^~~
chessboard.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 | #define bug(...) 826
      |                  ^~~
chessboard.cpp:52:9: note: in expansion of macro 'bug'
   52 |         bug(val);
      |         ^~~
chessboard.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 | #define bug(...) 826
      |                  ^~~
chessboard.cpp:55:9: note: in expansion of macro 'bug'
   55 |         bug(val);
      |         ^~~
chessboard.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 | #define bug(...) 826
      |                  ^~~
chessboard.cpp:58:9: note: in expansion of macro 'bug'
   58 |         bug(val);
      |         ^~~
chessboard.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 | #define bug(...) 826
      |                  ^~~
chessboard.cpp:61:9: note: in expansion of macro 'bug'
   61 |         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...