Submission #898186

# Submission time Handle Problem Language Result Execution time Memory
898186 2024-01-04T11:19:44 Z marcid Chessboard (IZhO18_chessboard) C++17
16 / 100
23 ms 3296 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define vi vector<int>
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define vii vector<ii>
#define viii vector<iii>
#define vb vector<bool>
#define pb push_back
#define eb emplace_back
const int maxn = 1e5+6;
const int inf = 1e18;
//010000 
//100000
//001101
//001100
//000010
//000000
//
//00000 
//00000
//00000
//00000
//00000
//
//what we need: number of painted black cells, number of cells, area of each square, 
void solve() { 
    int n, k; cin >> n >> k;
    int cells = n*n, bcells = 0, blacks = 0;
    vii top(k), bottom(k);
    set<int> factors; vi divs;
    for (int i = 0; i < k; i++) {
        cin >> top[i].first >> top[i].second >> bottom[i].first >> bottom[i].second;
        bcells += abs(top[i].first-bottom[i].first+1)*abs(top[i].second-bottom[i].second+1);
        blacks += (top[i].first+top[i].second)&1;
    } for (int i = 2; i*i<=n; i++) {
        if (n%i==0) factors.insert(i), factors.insert(n/i);
    } for (int i : factors) divs.eb(i);
    int mn = min(bcells+cells/2-2*blacks,cells-cells/2-bcells+2*blacks);
    if (!k) {
        for (int i : divs) {
            mn=min(mn,i*i*(((n/i)*(n/i))/2));
        }
    }
    for (int i = 0; i < divs.size(); i++) {
        int side = divs[i];
        int cntsq = n/side; // each
        
        //mn=min(mn,min(x,y));
    } cout << mn;// << ' ' << bcells << ' ' << blacks;
}
signed main() {
	cin.tie()->sync_with_stdio(0);
	int tc = 1;
	//cin >> tc;
	while (tc--) {
		solve(); 
        cout << '\n';
	}
}

Compilation message

chessboard.cpp: In function 'void solve()':
chessboard.cpp:48:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for (int i = 0; i < divs.size(); i++) {
      |                     ~~^~~~~~~~~~~~~
chessboard.cpp:50:13: warning: unused variable 'cntsq' [-Wunused-variable]
   50 |         int cntsq = n/side; // each
      |             ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2648 KB Output is correct
2 Correct 7 ms 860 KB Output is correct
3 Correct 10 ms 1628 KB Output is correct
4 Correct 11 ms 1884 KB Output is correct
5 Correct 17 ms 2296 KB Output is correct
6 Correct 10 ms 1372 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 9 ms 1568 KB Output is correct
9 Correct 23 ms 3296 KB Output is correct
10 Correct 14 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2648 KB Output is correct
2 Correct 7 ms 860 KB Output is correct
3 Correct 10 ms 1628 KB Output is correct
4 Correct 11 ms 1884 KB Output is correct
5 Correct 17 ms 2296 KB Output is correct
6 Correct 10 ms 1372 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 9 ms 1568 KB Output is correct
9 Correct 23 ms 3296 KB Output is correct
10 Correct 14 ms 1884 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 17 ms 2648 KB Output is correct
10 Correct 7 ms 860 KB Output is correct
11 Correct 10 ms 1628 KB Output is correct
12 Correct 11 ms 1884 KB Output is correct
13 Correct 17 ms 2296 KB Output is correct
14 Correct 10 ms 1372 KB Output is correct
15 Correct 2 ms 600 KB Output is correct
16 Correct 9 ms 1568 KB Output is correct
17 Correct 23 ms 3296 KB Output is correct
18 Correct 14 ms 1884 KB Output is correct
19 Incorrect 0 ms 348 KB Output isn't correct
20 Halted 0 ms 0 KB -