답안 #503854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
503854 2022-01-09T04:55:48 Z khangal Chessboard (IZhO18_chessboard) C++14
0 / 100
80 ms 38960 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<long long> vl;
typedef pair<long long, long long > pl;
const int N = 1e6 + 1;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18 
#define MIN -1e18
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
//typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
template< typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n, m, ans, mid, mn, mx, cnt, sum, h1, h2, arr[3234567],arr1[1234567], sz, k, i, j, h, a, w, x, y, z,par[1234567];
bool used[1234567];
ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123];
vector<ll> edge[1234567];
ll jump[22][223456];
ll lvl[1234567];
//ll bit[1234567];
//ll timer;
//ll st[1234567],endd[1234567];
//ll dp[5005][5005];
ll power(ll base, ll val, ll mod) {
    ll res = 1;
    while (val) {
        if (val % 2 == 1) {
            res = res * base;
        }
        base = base * base;
        base %= mod;
        res %= mod;
        val /= 2;
    }
    return res;
}
bool comp(pl x,pl y){
    if(x.ff>y.ff)return true;
    return false;
}
ll find(ll x){
    if(x==par[x])return x;
    else return par[x]=find(par[x]);
}
void process_LCA(){
    for(int i=1;(1<<i)<=n;i++){
        for(int j=1;j<=n;j++){
            jump[i][j] = jump[i-1][jump[i-1][j]];
        }
    }
}
ll LCA(ll x,ll y){
    if(lvl[x] < lvl[y])swap(x,y);
    ll diss = lvl[x] - lvl[y];
    for(int i=21;i>=0;i--){
        if((1<<i)&diss){
            x = jump[i][x];
        }
    }
    if(x==y)return x;
    for(int i=21;i>=0;i--){
        if(jump[i][x] != jump[i][y]){
            x = jump[i][x];
            y = jump[i][y];
        }
    }
    return jump[0][x];
}
ll find(ll x, ll d){
    return x / (2 * d) * d + min(x % (2 * d), d);
}
class A {
public:
    static void funcA(){
        cin>>n>>k;
        vl vec;
        for(ll i = 1; i * i <= n; i++){
            if(n % i == 0){
                vec.pb(i);
                if(i * i != n) vec.pb(n / i);
            }
        }        
        ll dif[1234567];
        for(ll i = 0; i < vec.size(); i++)
            dif[i] = n * n - n * n / (vec[i] * vec[i]) / 2 * (vec[i] * vec[i]);
        while(k--){
            ll x1, x2, y1, y2;
            cin>>x1>>y1>>x2>>y2;
            x1--; 
            y1--;
            for(ll i = 0; i < vec.size(); i++){
                ll xx,x3,yy,y3;
                xx = find(x2, vec[i]) - find(x1, vec[i]);
                x3 = x2 - x1 - xx;
                yy = find(y2, vec[i]) - find(y1, vec[i]);
                y3 = y2 - y1 - yy;
                dif[i] += xx * y3 + yy * x3 - xx * yy - x3 * y3;
            }
        }
        ans=MAX;
        for(int i=0;i<vec.size();i++){
            ans=min(ans , min(dif[i],n*n-dif[i]));
        }
        cout<<ans;
    }
}lol;
void solve() {
    A::funcA();
}
int main() {
    ll T = 1;
    //cin>>T;
    boost;
    while (T--) {
        solve();
    }
}

Compilation message

chessboard.cpp: In static member function 'static void A::funcA()':
chessboard.cpp:99:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |         for(ll i = 0; i < vec.size(); i++)
      |                       ~~^~~~~~~~~~~~
chessboard.cpp:106:29: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |             for(ll i = 0; i < vec.size(); i++){
      |                           ~~^~~~~~~~~~~~
chessboard.cpp:116:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  116 |         for(int i=0;i<vec.size();i++){
      |                     ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 38860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 80 ms 38948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 38960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 38960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 80 ms 38948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 38860 KB Output isn't correct
2 Halted 0 ms 0 KB -