Submission #598702

# Submission time Handle Problem Language Result Execution time Memory
598702 2022-07-18T18:10:01 Z mosiashvililuka Ancient Machine (JOI21_ancient_machine) C++17
95 / 100
74 ms 14332 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=18,J=13,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=18,J=13,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=18,J=13,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=18,J=13,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=18,J=13,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=18,J=13,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=18,J=13,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=18,J=13,JJ=20;
      |                                ^~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7676 KB Output is correct
2 Correct 9 ms 7580 KB Output is correct
3 Correct 9 ms 7572 KB Output is correct
4 Correct 9 ms 7572 KB Output is correct
5 Correct 11 ms 7580 KB Output is correct
6 Correct 9 ms 7576 KB Output is correct
7 Correct 8 ms 7572 KB Output is correct
8 Correct 10 ms 7584 KB Output is correct
9 Correct 9 ms 7572 KB Output is correct
10 Correct 7 ms 7572 KB Output is correct
11 Correct 9 ms 7580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 57 ms 14300 KB Partially correct
2 Partially correct 57 ms 14268 KB Partially correct
3 Partially correct 64 ms 14152 KB Partially correct
4 Partially correct 57 ms 14272 KB Partially correct
5 Partially correct 70 ms 14260 KB Partially correct
6 Partially correct 59 ms 14176 KB Partially correct
7 Partially correct 59 ms 14264 KB Partially correct
8 Partially correct 55 ms 14276 KB Partially correct
9 Partially correct 64 ms 14184 KB Partially correct
10 Partially correct 56 ms 14296 KB Partially correct
11 Partially correct 55 ms 14260 KB Partially correct
12 Partially correct 59 ms 14272 KB Partially correct
13 Partially correct 71 ms 14172 KB Partially correct
14 Partially correct 63 ms 14256 KB Partially correct
15 Partially correct 56 ms 14268 KB Partially correct
16 Partially correct 57 ms 14248 KB Partially correct
17 Partially correct 65 ms 14160 KB Partially correct
18 Partially correct 61 ms 14124 KB Partially correct
19 Partially correct 68 ms 14196 KB Partially correct
20 Partially correct 57 ms 14276 KB Partially correct
21 Partially correct 60 ms 14208 KB Partially correct
22 Partially correct 68 ms 14136 KB Partially correct
23 Partially correct 64 ms 14132 KB Partially correct
24 Partially correct 61 ms 14192 KB Partially correct
25 Partially correct 74 ms 14280 KB Partially correct
26 Partially correct 70 ms 14156 KB Partially correct
27 Partially correct 64 ms 14096 KB Partially correct
28 Partially correct 63 ms 14188 KB Partially correct
29 Partially correct 67 ms 14240 KB Partially correct
30 Partially correct 66 ms 14264 KB Partially correct
31 Partially correct 61 ms 14292 KB Partially correct
32 Partially correct 55 ms 14332 KB Partially correct
33 Partially correct 57 ms 14164 KB Partially correct