Submission #598581

# Submission time Handle Problem Language Result Execution time Memory
598581 2022-07-18T14:25:36 Z mosiashvililuka Ancient Machine (JOI21_ancient_machine) C++17
5 / 100
71 ms 14232 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(i=I+1; i<=a; i++){
        if(f[i]==2){
            /*if(c<i-1) g[i]=1;
            c=i;*/
            if(i!=I+1){
                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;
    vector <int> f(100009),Adp(100009);
    a=NN;L=LL;
    /*for(i=1; i<=a; i++){
        f[i]=AA[i-1];
    }*/
    if(AA[0]==0){
        for(i=1; i<=a; i++) rem(i);
        return;
    }
    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";*/

    //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;
      |                                      ^~
Anna.cpp:5:54: warning: unused variable 'JJ' [-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;
      |           ^
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;
      |                                ^~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 7572 KB Output is correct
2 Correct 13 ms 7584 KB Output is correct
3 Correct 14 ms 7556 KB Output is correct
4 Correct 14 ms 7580 KB Output is correct
5 Correct 14 ms 7584 KB Output is correct
6 Correct 13 ms 7580 KB Output is correct
7 Correct 16 ms 7580 KB Output is correct
8 Correct 14 ms 7576 KB Output is correct
9 Correct 13 ms 7524 KB Output is correct
10 Correct 11 ms 7632 KB Output is correct
11 Correct 10 ms 7580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 59 ms 14176 KB Partially correct
2 Partially correct 60 ms 14232 KB Partially correct
3 Incorrect 71 ms 14192 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -