Submission #88083

# Submission time Handle Problem Language Result Execution time Memory
88083 2018-12-03T17:49:02 Z cvetoslav Chessboard (IZhO18_chessboard) C++17
0 / 100
28 ms 656 KB
#include<bits/stdc++.h>
using namespace std;
void freesubtask1(int n)
{
    int minx=n*n/2;
    for(int d=2;d*d<=n;d++)
    {
        if(n%d==0)
        {
            int x=n/d;
            minx=min(minx,d*d/2*x*x);
        }
    }
    cout<<minx<<endl;
}
void freesubtask2(int n,int k)
{
    int br1=0,br2=0;
    for(int i=0;i<k;i++)
    {
        int x,y;
        cin>>x>>y>>x>>y;
        if(x%2==y%2) br1++;
        else br2++;
    }
    cout<<min(n*n/2-br2+br1,n*n/2+n%2-br1+br2)<<endl;
}
bool is_prime(int n)
{
    for(int i=2;i*i<=n;i++)
        if(n%i==0) return 0;
    return 1;
}
int main()
{
    ios_base::sync_with_stdio(0);
    srand(time(0));
    int n,k;
    cin>>n>>k;
    if(k==0) freesubtask1(n);
    else if(is_prime(n)) freesubtask2(n,k);
    else cout<<n*n/2<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 3 ms 656 KB Output is correct
8 Incorrect 3 ms 656 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 3 ms 656 KB Output is correct
8 Incorrect 3 ms 656 KB Output isn't correct