답안 #426626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426626 2021-06-14T08:10:06 Z 조영욱(#7645) Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
89 ms 8016 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[pr-1]]=true;
            Remove(vec[pr-1]);
            while (iter!=s.end()&&(*iter)<vec[pr]) {
                iter++;
                s.erase(prev(iter));
            }
        }
        else {
            Remove(vec[pr-1]);
            er[vec[pr-1]]=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];
      |     ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 484 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 89 ms 8016 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -