Submission #494367

#TimeUsernameProblemLanguageResultExecution timeMemory
494367Sho10Floppy (RMI20_floppy)C++17
100 / 100
104 ms13388 KiB
#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 (stderr)

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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...