Submission #408932

# Submission time Handle Problem Language Result Execution time Memory
408932 2021-05-19T19:59:36 Z Atill83 DEL13 (info1cup18_del13) C++14
0 / 100
55 ms 10492 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void solve(){
    int n, q;
    cin>>n>>q;
    vector<int> islem;
    vector<set<int>> once = {{}};
    vector<int> a = {0};
    cerr<<"garip kont 1"<<endl;
    for(int i = 0; i < q; i++){
        int x;
        cin>>x;
        once.push_back(set<int>());
        for(int j = a.back() + 1; j < x; j++){
            once.back().insert(j);
        }

        while(once.back().size() > 3){
            auto u = once.back().begin();
            u = once.back().erase(u);
            islem.push_back((*u));
            u = next(u);
            u = once.back().erase(u);
        }

        a.push_back(x);
    }
    once.push_back(set<int>());
    
    for(int j = a.back() + 1; j <= n; j++)
        once.back().insert(j);
    while(once.back().size() > 3){
        auto u = once.back().begin();
        u = once.back().erase(u);
        islem.push_back((*u));
        u = next(u);
        u = once.back().erase(u);
    }
    if(q < 1 && n != 1){
        cout<<-1<<endl;
        return;
    }
    cerr<<"garip kont 2"<<endl;

    vector<vector<bool>> dp(q + 2, vector<bool>(3, 0));
    vector<vector<pii>> prev(q + 2, vector<pii>(4));
    cerr<<q + 1<<" "<<once.size()<<endl;
    dp[0][once[1].size()] = 1;
    for(int i = 1; i <= q; i++){
        for(int l = 0; l <= once[i + 1].size(); l++){
            int is = (int) once[i + 1].size() - l;
            dp[i][l] = dp[i - 1][is];
            prev[i][l] = {is, 0};
        }
    }


    cerr<<"garip kont 3"<<endl;
    if(dp[q][0]){
        int l = 0;
        /*for(int j = q; j >= 1; j--){ // l j'nin kac biraktigi, cur.ff kac tane yaptigi ayni zamanda oncekinin kac biraktigi
            pii cur = prev[j][l];
            if(cur.ss == 0){
                for(int i = 0; i < cur.ff; i++){
                    islem.push_back(j);
                }
                l = once[j].size() - cur.ff;
            }
        }*/

        cout<<islem.size()<<endl;
        for(int i: islem)
            cout<<i<<" ";
        cout<<endl;
    }else{
        cout<<-1<<endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
    #endif

    int t;
    cin>>t;

    while(t--)
        solve();



    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Compilation message

del13.cpp: In function 'void solve()':
del13.cpp:62:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int l = 0; l <= once[i + 1].size(); l++){
      |                        ~~^~~~~~~~~~~~~~~~~~~~~
del13.cpp:72:13: warning: unused variable 'l' [-Wunused-variable]
   72 |         int l = 0;
      |             ^
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 336 KB Output isn't correct
2 Incorrect 11 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 336 KB Output isn't correct
2 Incorrect 11 ms 332 KB Output isn't correct
3 Incorrect 55 ms 332 KB Output isn't correct
4 Incorrect 52 ms 352 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 592 KB Output isn't correct
2 Incorrect 43 ms 2496 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 336 KB Output isn't correct
2 Incorrect 11 ms 332 KB Output isn't correct
3 Incorrect 55 ms 332 KB Output isn't correct
4 Incorrect 52 ms 352 KB Output isn't correct
5 Incorrect 4 ms 332 KB Output isn't correct
6 Incorrect 4 ms 332 KB Output isn't correct
7 Incorrect 3 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 336 KB Output isn't correct
2 Incorrect 11 ms 332 KB Output isn't correct
3 Incorrect 55 ms 332 KB Output isn't correct
4 Incorrect 52 ms 352 KB Output isn't correct
5 Incorrect 4 ms 332 KB Output isn't correct
6 Incorrect 4 ms 332 KB Output isn't correct
7 Incorrect 3 ms 332 KB Output isn't correct
8 Incorrect 42 ms 2580 KB Output isn't correct
9 Incorrect 42 ms 4296 KB Output isn't correct
10 Incorrect 41 ms 5196 KB Output isn't correct
11 Incorrect 43 ms 10492 KB Output isn't correct