Submission #598700

# Submission time Handle Problem Language Result Execution time Memory
598700 2022-07-18T18:03:31 Z mosiashvililuka Ancient Machine (JOI21_ancient_machine) C++17
93 / 100
83 ms 14720 KB
#include<bits/stdc++.h>
#include "Anna.h"
using namespace std;
void Anna(int NN, std::vector<char> SS) {
    long long a,b,c,d,e,i,j,ii,jj,zx,xc,I,LI=19,J=14,JJ=20;
    vector <long long> f(100009),dp(600009),g(100009);
    a=NN;
    for(i=1; i<=a; i++){
        if(SS[i-1]=='X') f[i]=0;
        if(SS[i-1]=='Y') f[i]=1;
        if(SS[i-1]=='Z') f[i]=2;
    }
    //
    zx=0;
    for(i=0; i<(1<<LI); i++){
        e=0;
        for(j=1; j<LI; j++){
            jj=j-1;
            if((i&(1<<jj))!=0&&(i&(1<<j))!=0){
                e=1;
                break;
            }
        }
        if(e==1) continue;
        zx++;dp[i]=zx;
    }
    //cout<<zx<<"\n";
    for(i=1; i<=a; i++){
        if(f[i]==0){
            break;
        }
    }
    I=i;
    if(I>a) I=0;
    //if(I==0) Send(0); else Send(1);
    /*for(j=0; j<JJ; j++){
        if((I&(1<<j))!=0) Send(1); else Send(0);
    }*/
    //g[I]=1;
    c=I;
    for(j=0; j<JJ; j++){
        if((I&(1<<j))!=0) Send(1); else Send(0);
    }
    for(i=I+1; i<=a; i++){
        if(f[i]==2){
            /*if(c<i-1) g[i]=1;
            c=i;*/
            if(f[i+1]!=2) g[i]=1;
        }
    }
    /*for(i=1; i<=a; i++) cout<<g[i]<<" ";
    cout<<"gend\n";*/
    for(i=1; i<=a; i+=LI){
        zx=0;
        for(j=i; j<=min(i+LI-1,a); j++){
            if(g[j]==1) zx^=(1<<(j-i));
        }
        c=dp[zx];
        for(j=0; j<J; j++){
            if((c&(1<<j))!=0) Send(1); else Send(0);
        }
    }
}
#include<bits/stdc++.h>
#include "Bruno.h"
using namespace std;
namespace {
void rem(int q){
    Remove(q-1);
}
}
void Bruno(int NN, int LL, std::vector<int> AA) {
    int a,b,c,d,e,i,j,ii,jj,zx,xc,L,I,LI=19,J=14,JJ=20;
    vector <int> f(100009),Adp(100009);
    a=NN;L=LL;
    /*for(i=1; i<=a; i++){
        f[i]=AA[i-1];
    }*/
    I=0;
    for(j=0; j<JJ; j++){
        if(AA[j]==1) I+=(1<<j);
    }
    if(I==0){
        for(i=1; i<=a; i++) rem(i);
        return;
    }
    for(j=JJ; j<L; j++){
        AA[j-(JJ-1)]=AA[j];
    }
    L-=(JJ-1);
    zx=0;
    for(i=0; i<(1<<LI); i++){
        e=0;
        for(j=1; j<LI; j++){
            jj=j-1;
            if((i&(1<<jj))!=0&&(i&(1<<j))!=0){
                e=1;
                break;
            }
        }
        if(e==1) continue;
        zx++;//dp[i]=zx;
        Adp[zx]=i;
    }
    /*for(i=1; i<L; i++) cout<<AA[i]<<" ";
    cout<<"\n";*/
    int id=1;
    for(i=1; i<L; i+=J){
        zx=0;
        for(j=i; j<=min(i+J-1,L-1); j++){
            if(AA[j]==1){
                zx+=(1<<(j-i));
            }
       }
       c=Adp[zx];
       for(j=id; j<=min(id+LI-1,a); j++){
            d=j-id;
            f[j]=(c&(1<<d));
            if(f[j]!=0) f[j]=1;
       }
       id+=LI;
    }



    /*for(i=1; i<=a; i++) cout<<f[i]<<" ";
    cout<<"\n";*/
    f[I]=1;

    //solve
    for(i=1; i<=a; i++){
        if(f[i]==1){
            break;
        }
        rem(i);
    }
    if(i>a) return;
    I=i;ii=i;
    for(i=I+1; i<=a; i++){
        if(f[i]==1){
            for(j=i-1; j>ii; j--) rem(j);
            rem(i);
            ii=i;
            continue;
        }
    }
    for(i=a; i>ii; i--) rem(i);
    rem(I);
}

Compilation message

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:5:17: warning: unused variable 'b' [-Wunused-variable]
    5 |     long long a,b,c,d,e,i,j,ii,jj,zx,xc,I,LI=19,J=14,JJ=20;
      |                 ^
Anna.cpp:5:21: warning: unused variable 'd' [-Wunused-variable]
    5 |     long long a,b,c,d,e,i,j,ii,jj,zx,xc,I,LI=19,J=14,JJ=20;
      |                     ^
Anna.cpp:5:29: warning: unused variable 'ii' [-Wunused-variable]
    5 |     long long a,b,c,d,e,i,j,ii,jj,zx,xc,I,LI=19,J=14,JJ=20;
      |                             ^~
Anna.cpp:5:38: warning: unused variable 'xc' [-Wunused-variable]
    5 |     long long a,b,c,d,e,i,j,ii,jj,zx,xc,I,LI=19,J=14,JJ=20;
      |                                      ^~

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:10:11: warning: unused variable 'b' [-Wunused-variable]
   10 |     int a,b,c,d,e,i,j,ii,jj,zx,xc,L,I,LI=19,J=14,JJ=20;
      |           ^
Bruno.cpp:10:32: warning: unused variable 'xc' [-Wunused-variable]
   10 |     int a,b,c,d,e,i,j,ii,jj,zx,xc,L,I,LI=19,J=14,JJ=20;
      |                                ^~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 7672 KB Output is correct
2 Correct 14 ms 7584 KB Output is correct
3 Correct 18 ms 7556 KB Output is correct
4 Correct 14 ms 7656 KB Output is correct
5 Correct 13 ms 7660 KB Output is correct
6 Correct 17 ms 7576 KB Output is correct
7 Correct 15 ms 7576 KB Output is correct
8 Correct 15 ms 7584 KB Output is correct
9 Correct 16 ms 7556 KB Output is correct
10 Correct 11 ms 7584 KB Output is correct
11 Correct 11 ms 7584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 66 ms 14552 KB Partially correct
2 Partially correct 68 ms 14640 KB Partially correct
3 Partially correct 69 ms 14584 KB Partially correct
4 Partially correct 61 ms 14700 KB Partially correct
5 Partially correct 66 ms 14700 KB Partially correct
6 Partially correct 64 ms 14608 KB Partially correct
7 Partially correct 70 ms 14660 KB Partially correct
8 Partially correct 67 ms 14720 KB Partially correct
9 Partially correct 68 ms 14568 KB Partially correct
10 Partially correct 66 ms 14692 KB Partially correct
11 Partially correct 65 ms 14580 KB Partially correct
12 Partially correct 65 ms 14588 KB Partially correct
13 Partially correct 76 ms 14616 KB Partially correct
14 Partially correct 73 ms 14540 KB Partially correct
15 Partially correct 66 ms 14572 KB Partially correct
16 Partially correct 65 ms 14584 KB Partially correct
17 Partially correct 73 ms 14592 KB Partially correct
18 Partially correct 75 ms 14552 KB Partially correct
19 Partially correct 75 ms 14572 KB Partially correct
20 Partially correct 66 ms 14672 KB Partially correct
21 Partially correct 62 ms 14592 KB Partially correct
22 Partially correct 74 ms 14580 KB Partially correct
23 Partially correct 65 ms 14696 KB Partially correct
24 Partially correct 75 ms 14604 KB Partially correct
25 Partially correct 68 ms 14680 KB Partially correct
26 Partially correct 83 ms 14668 KB Partially correct
27 Partially correct 70 ms 14572 KB Partially correct
28 Partially correct 79 ms 14688 KB Partially correct
29 Partially correct 76 ms 14476 KB Partially correct
30 Partially correct 68 ms 14484 KB Partially correct
31 Partially correct 64 ms 14460 KB Partially correct
32 Partially correct 70 ms 14568 KB Partially correct
33 Partially correct 80 ms 14548 KB Partially correct