제출 #1323283

#제출 시각아이디문제언어결과실행 시간메모리
1323283yswangAliens (IOI16_aliens)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define square(x) ((x)*(x))

int take_photo(int &n, int &m, int &k, vector<int> &r, vector<int> &c){
    vector<pair<int, int>> ori(n);  // 0-base
    for (int i=0; i<n; i++) ori[i] = {min(r[i], c[i]), max(r[i], c[i])};
    sort(ori.begin(), ori.end());
    vector<pair<int, int>> stars{};  // 0-base
    for (int i=0; i<n; i++){
        if (stars.empty()) stars.push_back(ori[i]);
        else if (stars.back().first==ori[i].first) stars.pop_back();
        else if (stars.back().second < ori[i].second) stars.push_back(ori[i]);
    }

    n = stars.size();
    vector<vector<int>> dp(k, vector<int>(n));
    for (int i=0; i<k; i++){
        for (int j=0; j<n; j++){
            if (j<i) dp[i][j] = 0;
            else if (i==0){
                dp[i][j] = square(stars[j].second-stars[0].first+1);
            }else{
                dp[i][j] = m*m;
                for (int h=i+1; h<=j; h++){
                    int area = square(stars[j].second-stars[h].first+1);
                    int over = (h>1) ? square(max(0LL, (stars[h-1].second-stars[h].first+1))) : 0;
                    dp[i][j] = min(dp[i][j], dp[i-1][h-1]+area-over);
                }
            }
        }
    }
    return dp[k-1][n-1];
}

signed main(){
    int n, m, k;
    cin>>n>>m>>k;
    vector<int> r(n), c(n);
    for (int i=0; i<n; i++) cin>>r[i]>>c[i];
    cout<<take_photo(n, m, k, r, c)<<'\n';
}

컴파일 시 표준 에러 (stderr) 메시지

aliens.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
aliens_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
/usr/bin/ld: /tmp/ccPklbxn.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccssEEWF.o:aliens.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccPklbxn.o: in function `main':
grader.cpp:(.text.startup+0xff): undefined reference to `take_photos(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status