Submission #426631

# Submission time Handle Problem Language Result Execution time Memory
426631 2021-06-14T08:16:18 Z 조영욱(#7645) Ancient Machine (JOI21_ancient_machine) C++17
30 / 100
166 ms 14284 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

int variable_example = 0;

}

void Anna(int n,vector<char> s) {
    for(int i=0;i<n;i++) {
        int val=s[i]-'X';
        Send(val/2);
        Send(val%2);
    }
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

int dp[262144];
int pr[262144];
int arr[250000];
bool er[250000];
int n;
}  // namespace

void Bruno(int nn,int l,vector<int> v) {
    n=nn;
  for (int i = 0;i<l;i+=2) {
    arr[i/2]=v[i]*2+v[i+1];
  }
    set<int> s;
    for(int i=0;i<n;i++) {
        if (arr[i]==1) {
            s.insert(i);
        }
    }
    vector<int> vec;
    bool flag=false;
    for(int i=0;i<n;i++) {
        if (arr[i]==0) {
            flag=true;
        }
        if (flag&&arr[i]!=1)
            vec.push_back(i);
    }
    int sz=vec.size();
    for(int i=sz-1;i>=0;i--) {
        if (arr[vec[i]]==2) {
            break;
        }
        sz--;
    }
    vec.resize(sz);
    for(int i=1;i+1<vec.size();i++) {
        if (arr[vec[i]]==0) {
            continue;
        }
        auto iter=s.upper_bound(vec[i-1]);
        if (iter!=s.end()&&(*iter)<vec[i]) {
            for(int j=vec[i-1]+1;j<vec[i];j++) {
                    er[j]=true;
                if (j!=(*iter)) {
                    Remove(j);
                }
            }
            Remove((*iter));
            er[vec[i]]=true;
            Remove(vec[i]);
            while (iter!=s.end()&&(*iter)<vec[i]) {
                iter++;
                s.erase(prev(iter));
            }
        }
        else {
            Remove(vec[i]);
            er[vec[i]]=true;
        }
    }
    int pr=(int)vec.size()-1;
    for(int i=(int)vec.size()-2;i>=0;i--) {
        if (arr[vec[i]]==2) {
            continue;
        }
        auto iter=s.upper_bound(vec[pr-1]);
        if (iter!=s.end()&&(*iter)<vec[pr]) {
            for(int j=vec[pr-1]+1;j<vec[pr];j++) {
                    er[j]=true;
                if (j!=(*iter)) {
                    Remove(j);
                }
            }
            Remove((*iter));
            er[vec[i]]=true;
            Remove(vec[i]);
            while (iter!=s.end()&&(*iter)<vec[pr]) {
                iter++;
                s.erase(prev(iter));
            }
        }
        else {
            Remove(vec[i]);
            er[vec[i]]=true;
        }
        pr=i;
    }
    for(int i=0;i<n;i++) {
        if (!er[i]) {
            Remove(i);
        }
    }
}

Compilation message

Anna.cpp:7:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    7 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i=1;i+1<vec.size();i++) {
      |                 ~~~^~~~~~~~~~~
Bruno.cpp: At global scope:
Bruno.cpp:8:5: warning: '{anonymous}::pr' defined but not used [-Wunused-variable]
    8 | int pr[262144];
      |     ^~
Bruno.cpp:7:5: warning: '{anonymous}::dp' defined but not used [-Wunused-variable]
    7 | int dp[262144];
      |     ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 484 KB Output is correct
2 Correct 2 ms 552 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 1 ms 484 KB Output is correct
6 Correct 1 ms 484 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 2 ms 480 KB Output is correct
10 Correct 2 ms 484 KB Output is correct
11 Correct 2 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 120 ms 9792 KB Partially correct
2 Partially correct 99 ms 9792 KB Partially correct
3 Partially correct 100 ms 9720 KB Partially correct
4 Partially correct 107 ms 9768 KB Partially correct
5 Partially correct 99 ms 9832 KB Partially correct
6 Partially correct 113 ms 9832 KB Partially correct
7 Partially correct 103 ms 9740 KB Partially correct
8 Partially correct 107 ms 9728 KB Partially correct
9 Partially correct 106 ms 9736 KB Partially correct
10 Partially correct 97 ms 9736 KB Partially correct
11 Partially correct 109 ms 9736 KB Partially correct
12 Partially correct 104 ms 9820 KB Partially correct
13 Partially correct 107 ms 9784 KB Partially correct
14 Partially correct 111 ms 9740 KB Partially correct
15 Partially correct 103 ms 9796 KB Partially correct
16 Partially correct 97 ms 9736 KB Partially correct
17 Partially correct 108 ms 9812 KB Partially correct
18 Partially correct 120 ms 14076 KB Partially correct
19 Partially correct 93 ms 9368 KB Partially correct
20 Partially correct 106 ms 9696 KB Partially correct
21 Partially correct 119 ms 9744 KB Partially correct
22 Partially correct 132 ms 14284 KB Partially correct
23 Partially correct 110 ms 9740 KB Partially correct
24 Partially correct 111 ms 9800 KB Partially correct
25 Partially correct 141 ms 14076 KB Partially correct
26 Partially correct 145 ms 14284 KB Partially correct
27 Partially correct 166 ms 14132 KB Partially correct
28 Partially correct 127 ms 14092 KB Partially correct
29 Partially correct 125 ms 14104 KB Partially correct
30 Partially correct 133 ms 14156 KB Partially correct
31 Partially correct 122 ms 14064 KB Partially correct
32 Partially correct 102 ms 9736 KB Partially correct
33 Partially correct 139 ms 9744 KB Partially correct