Submission #966969

# Submission time Handle Problem Language Result Execution time Memory
966969 2024-04-20T18:12:04 Z MarwenElarbi Aliens (IOI16_aliens) C++17
0 / 100
1 ms 348 KB
//#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c){
    set<int> st;
    for (int i = 0; i < n; ++i)
    {
        st.insert(r[i]);
    }
    if(k>=n) return st.size();
    vector<int> tab;
    tab.push_back(-1);
    for(auto u:st) tab.push_back(u);
    int dp[tab.size()][k+1];
    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= k; ++j)
        {
            dp[i][j]=1e9;
        }
    }
    int ans=m*m;
    dp[0][0]=0;
    for (int i = 1; i <= tab.size(); ++i)
    {
        int lst=tab[i];
        int cur=1;
        for (int j = i; j >= 0 ; --j)
        {
            //cout <<i<<" "<<j<<" "<<cur<<" "<<dp[j-1][1]<<endl;
            if(j==0){
                //cout <<i<<endl;
                dp[i][1]=cur*cur;
            }else{
                cur+=lst-tab[j];
                lst=tab[j];
                for (int t = 1; t <= k; ++t)
                {
                    dp[i][t]=min(dp[i][t],dp[j-1][t-1]+cur*cur);
                }
            }
            
        }
    }
    for (int i = 0; i <= k; ++i)
    {
       ans=min(ans,dp[tab.size()-1][k]); 
    }
    return ans;
}

Compilation message

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i = 1; i <= tab.size(); ++i)
      |                     ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Correct answer: answer = 1
2 Correct 0 ms 348 KB Correct answer: answer = 4
3 Runtime error 1 ms 348 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer: output = 1, expected = 4
2 Halted 0 ms 0 KB -