Submission #619278

# Submission time Handle Problem Language Result Execution time Memory
619278 2022-08-02T10:54:21 Z Dremix10 Aliens (IOI16_aliens) C++17
12 / 100
311 ms 489448 KB
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
    #define pp(x) cerr<<#x<<" = "<<x.F<<"-"<<x.S<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v<<", ";cerr<<"}"<<endl;
    #define ppv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v.F<<"-"<<v.S<<", ";cerr<<"}"<<endl;
#else
    #define p(x) {}
    #define p2(x,y) {}
    #define pp(x) {}
    #define pv(x) {}
    #define ppv(x) {}
#endif
const int N = 1005;
const int MOD = 1e9+7;
const ll INF = 1e18+5;

struct ano{
    int x,y,id;
};

bool cmp(ano a, ano b){
    return min(a.x,a.y) > min(b.x,b.y);
}

bool v[N][N];

void clean(vector<ano> &a){
    while(!a.empty() && v[a.back().x][a.back().y])
        a.pop_back();
}

void print(vector<ano> &arr){
    return;
    for(auto x : arr){
        cerr<<x.x<<" "<<x.y<<" "<<x.id<<endl;
    }
}

long long take_photos(int n, int m, int K, std::vector<int> r, std::vector<int> c) {
    int i,j,k;

    //vector<ano> arr(n);
    set<pi> s;

    for(i=0;i<n;i++){
        s.insert({r[i],c[i]});
    }
    vector<int> arr;
    n = s.size();

    for(auto x : s)
        arr.push_back(x.F);

    //bool v[m][m] = {};
    int dp[n][n][K];

    //memset(dp,MOD,sizeof(dp));

    for(i=0;i<n;i++)for(j=0;j<=i;j++)for(k=0;k<K;k++){
        //cerr<<dp[i][j][k]<<" ";
        dp[i][j][k] = MOD;
    }
    dp[0][0][K-1] = 1;
    int pref[n+1];
    int curr,nxt,net;
    pv(arr)
    for(i=0;i<n-1;i++)for(j=0;j<=i;j++){
        curr = (arr[i]-arr[j]+1)*(arr[i]-arr[j]+1);
        nxt = (arr[i+1]-arr[j]+1)*(arr[i+1]-arr[j]+1);
        net = nxt - curr;
        for(k=0;k<K;k++){
            if(k > 0)
                dp[i+1][i+1][k-1] = min(dp[i+1][i+1][k-1],dp[i][j][k] + 1);
            
            dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]+net);
        }
    }
    int ans = MOD;
    for(j=0;j<n;j++)
    for(i=0;i<K;i++)
        ans = min(ans,dp[n-1][j][i]);
    return ans;
}

Compilation message

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:75:9: warning: unused variable 'pref' [-Wunused-variable]
   75 |     int pref[n+1];
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Correct answer: answer = 1
2 Correct 1 ms 212 KB Correct answer: answer = 4
3 Correct 0 ms 212 KB Correct answer: answer = 1
4 Correct 0 ms 304 KB Correct answer: answer = 5
5 Correct 1 ms 308 KB Correct answer: answer = 41
6 Correct 1 ms 212 KB Correct answer: answer = 71923
7 Correct 1 ms 1620 KB Correct answer: answer = 77137
8 Correct 111 ms 151444 KB Correct answer: answer = 764
9 Correct 2 ms 1236 KB Correct answer: answer = 250000
10 Correct 311 ms 489448 KB Correct answer: answer = 500
11 Correct 1 ms 212 KB Correct answer: answer = 32
12 Correct 2 ms 2260 KB Correct answer: answer = 130050
13 Correct 42 ms 48192 KB Correct answer: answer = 5110
14 Correct 5 ms 6740 KB Correct answer: answer = 2626
15 Correct 16 ms 21584 KB Correct answer: answer = 796
16 Correct 26 ms 32596 KB Correct answer: answer = 7580
17 Correct 110 ms 130472 KB Correct answer: answer = 1904
18 Correct 1 ms 852 KB Correct answer: answer = 996004
19 Correct 10 ms 12628 KB Correct answer: answer = 38817
20 Correct 42 ms 59852 KB Correct answer: answer = 4096
21 Correct 1 ms 212 KB Correct answer: answer = 1
22 Correct 1 ms 212 KB Correct answer: answer = 1
23 Correct 83 ms 120676 KB Correct answer: answer = 2040
24 Correct 1 ms 212 KB Correct answer: answer = 2
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -