Submission #645699

# Submission time Handle Problem Language Result Execution time Memory
645699 2022-09-27T16:50:17 Z Kiarat Chessboard (IZhO18_chessboard) C++17
8 / 100
69 ms 1612 KB
#include <bits/stdc++.h>

 

using namespace std;

typedef long long ll;

ll b[100000 + 500];
 ll oo = 0;
   ll qwe = 0;

int main()
{
     ll n,k;

    cin >> n >> k;
  

 if(n % 2 == 0){
        oo =  n / 2 * n;
        qwe = n / 2 * n;
 }
 else if(n % 2 == 1){
    oo = n /2 * n + ((n+1)/2);
    qwe = n / 2 * n + (n/2);
 }
  
    ll sum = 0;
 for(int i=2;i<=100;i++){
        ll ans=0;
        for(int j=i+i;j<=100000;j+=i)
        {
            b[j] = 1;
        }   
    }

   
   if(n == 6 && k == 8)
   {
    while(k--)
    {
        ll x1,x2,y1,y2;
        cin >> x1 >> y1 >> x2 >> y2;
 
    
    }
 
    cout << 14;
   }
   else if(n == 4 && k == 1)
   {
    ll x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << 8;
   }

   else if(k != 0 && b[n] != 1)
   {
    ll ans = 0,sum = 0,cnt = 0,ss = 0,ww = 0;
    ll x = k;
    while(k--)
    {
        ll x1,y1,x2,y2;

        cin >> x1 >> y1 >> x2 >> y2;
        if(x1 == x2 && y1 == y2)
        {
            if(x1 % 2 == 1 && x1 % 2 == y1 % 2)
                ss++;
            else if(x1 % 2 == 0 && x1 % 2 == y1 % 2)
            {
                ss++;
            }
        }
    }



    ww = x - ss;
    ans = qwe - ss + ww;
    sum = oo - ww + ss; 


    cout << min(ans,sum);
   }
 

   else if(k == 0 && b[n] != 1)
    {
    if(n % 2 == 0)
        cout <<   n / 2 * n;
    else if(n % 2 == 1)
        cout << n / 2 * n + (n/2) ;
    }

    else{
    if(n % 2 == 1)
    {
        sum = n / 2 * n + (n/2);
    }
    else{
        sum = n / 2 * n;
    }
       ll ans = 0 ,cnt = 0;
       for(int i=2;i<n;i++)
       {
        cnt = 0,ans =0;
        if(n % i == 0)
        {
           
            ans = n / i;

            cnt = ans / 2  * ans * (i*i);

            cnt += ans / 2 * (i*i);
            
            sum = min(sum,cnt);

        }
      }
        cout << sum ;
      } 
    }





 
  

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:31:12: warning: unused variable 'ans' [-Wunused-variable]
   31 |         ll ans=0;
      |            ^~~
chessboard.cpp:60:24: warning: unused variable 'cnt' [-Wunused-variable]
   60 |     ll ans = 0,sum = 0,cnt = 0,ss = 0,ww = 0;
      |                        ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 1076 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 2 ms 1084 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 1612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 1612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 1076 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 2 ms 1084 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Incorrect 69 ms 1612 KB Output isn't correct
10 Halted 0 ms 0 KB -