제출 #1368934

#제출 시각아이디문제언어결과실행 시간메모리
1368934marizaAliens (IOI16_aliens)C++20
0 / 100
0 ms344 KiB
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

long long take_photos(int n, int m, int k, vector<int> r, vector<int> c){
    vector<pair<ll,ll>> a;
    for(ll i=0; i<n; i++){
        if(c[i]<r[i]) swap(c[i],r[i]);
        a.push_back({r[i],-c[i]});
    }

    r.clear();
    c.clear();
    sort(a.begin(),a.end());
    r.push_back(a[0].first-1);
    c.push_back(-a[0].second);
    n=a.size();

    ll x=-a[0].second;
    // cout<<n<<endl;
    for(ll i=1; i<n; i++){
        // cout<<i<<endl;
        if(-a[i].second>x){
            r.push_back(a[i].first-1);
            c.push_back(-a[i].second);
            x=-a[i].second;
        }
    }
    n=r.size();
    // cout<<n<<endl;

    ll ans=(c[0]-r[0])*(c[0]-r[0]);
    for(ll i=1; i<n; i++){
        assert(c[i]>c[i-1]);
        ans+=(c[i]-r[i])*(c[i]-r[i])-(c[i-1]-r[i])*(c[i-1]-r[i]);
    }
    return ans;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…