Submission #92933

#TimeUsernameProblemLanguageResultExecution timeMemory
92933MakhsudChessboard (IZhO18_chessboard)C++17
0 / 100
2 ms504 KiB
#include <bits/stdc++.h> #define ll long long ll n, k, x, y, xx, yy; ll d; bool used[150][150], pr = false; using namespace std; int main() { cin >> n >> k; for ( int i = 1; i <= k; i ++ ) { cin >> x >> y >> xx >> yy; used[x][y] = true; } ll cn = 0; for ( int i = 1; i <= n; i ++ ) { if ( n % i == 0 ) cn ++; } if ( cn == 2 ) { bool f1 = true; ll ans = 0, mn, ans1 = 0; for ( int i = 1; i <= n; i ++ ) { for ( int j = 1; j <= n; j ++ ) { if ( i % 2 == 1 ) { if ( j % 2 == 1 ) { if ( !used[i][j] ) ans ++; } else { if ( used[i][j] ) ans ++; } } if ( i % 2 == 0 ) { if ( j % 2 == 0 ) { if ( !used[i][j] ) ans ++; } else { if ( used[i][j] ) ans ++; } } } } for ( int i = 1; i <= n; i ++ ) { for ( int j = 1; j <= n; j ++ ) { if ( i % 2 == 1 ) { if ( j % 2 == 0 ) { if ( !used[i][j] ) ans1 ++; } else { if ( used[i][j] ) ans1 ++; } } if ( i % 2 == 0 ) { if ( j % 2 == 1 ) { if ( !used[i][j] ) ans1 ++; } else { if ( used[i][j] ) ans1 ++; } } } } cout << min ( ans, ans1 ); return 0; } for ( int i = n-1; i >= 1; i -- ) { if ( n % i == 0 ) { d = i; break; } } if ( d == 1 ) { cout << (n*n) / 2; } else { ll cnt = 0; bool ch = false; for ( int i = 1; i <= n; i += d ) { ch = !ch; if ( ch ) { cnt += ( n / d ) / 2; } else { cnt += ( n / d + 1 ) / 2; } } cout << cnt * (d*d); } }

Compilation message (stderr)

chessboard.cpp: In function 'int main()':
chessboard.cpp:22:8: warning: unused variable 'f1' [-Wunused-variable]
   bool f1 = true;
        ^~
chessboard.cpp:23:15: warning: unused variable 'mn' [-Wunused-variable]
   ll ans = 0, mn, ans1 = 0;
               ^~
#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...