답안 #494367

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494367 2021-12-15T10:30:52 Z Sho10 Floppy (RMI20_floppy) C++17
100 / 100
104 ms 13388 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho
#include "floppy.h"
#define ll long long int
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define aint(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 998244353
#define PI 3.14159265359
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll dp[20][400005];
void read_array ( int subtask_id , const std :: vector <int > & v ){
string bits="";
stack<ll>s;
s.push(-1);
for(ll i=0;i<v.size();i++)
{
    while(s.top()!=-1&&v[s.top()]<v[i]){
        bits+='0';
        s.pop();
    }
    s.push(i);
    bits+='1';
}
save_to_floppy(bits);
}
vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int>&a, const vector<int>&b){
stack<ll>s;
s.push(-1);
ll pos=0;
ll j=0;
while(pos<N){
    while(bits[j]=='0'){
        j++;
        s.pop();
    }
    dp[0][pos+1]=s.top()+1;
    s.push(pos);
    pos++;
    j++;
}
for(ll i=1;(1ll<<i)<=N;i++)
{
    for(ll j=1;j<=N;j++)
    {
        dp[i][j]=dp[i-1][dp[i-1][j]];
    }
}
vector<int>ans;
for(ll i=0;i<a.size();i++)
{
    ll x=b[i]+1;
    for(ll j=15;j>=0;j--)
    {
        if((1ll<<j)>N){
            continue;
        }
        if(dp[j][x]>=a[i]+1){
            x=dp[j][x];
        }
    }
    ans.pb(x-1);
}
return ans;
}

Compilation message

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:26:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 | for(ll i=0;i<v.size();i++)
      |            ~^~~~~~~~~
floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:60:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 | for(ll i=0;i<a.size();i++)
      |            ~^~~~~~~~~
stub.cpp: In function 'void run2()':
stub.cpp:101:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  101 |     if (query_answers.size() != M) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 764 KB Output is correct
2 Correct 2 ms 764 KB Output is correct
3 Correct 2 ms 776 KB Output is correct
4 Correct 2 ms 760 KB Output is correct
5 Correct 2 ms 740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3620 KB Output is correct
2 Correct 20 ms 3572 KB Output is correct
3 Correct 20 ms 3688 KB Output is correct
4 Correct 26 ms 3628 KB Output is correct
5 Correct 24 ms 3592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 13052 KB Output is correct
2 Correct 86 ms 13388 KB Output is correct
3 Correct 104 ms 13196 KB Output is correct
4 Correct 89 ms 13252 KB Output is correct
5 Correct 93 ms 13120 KB Output is correct