Submission #1358862

#TimeUsernameProblemLanguageResultExecution timeMemory
1358862almaarmudBubble Sort Machine (JOI25_bubble)C++20
Compilation error
0 ms0 KiB
/*  █████╗ ██╗     ███╗   ███╗ █████╗  █████╗ ██████╗ ███╗   ███╗██╗   ██╗██████╗
   ██╔══██╗██║     ████╗ ████║██╔══██╗██╔══██╗██╔══██╗████╗ ████║██║   ██║██╔══██╗
   ███████║██║     ██╔████╔██║███████║███████║██████╔╝██╔████╔██║██║   ██║██║  ██║
   ██╔══██║██║     ██║╚██╔╝██║██╔══██║██╔══██║██╔══██╗██║╚██╔╝██║██║   ██║██║  ██║
   ██║  ██║███████╗██║ ╚═╝ ██║██║  ██║██║  ██║██║  ██║██║ ╚═╝ ██║╚██████╔╝██████╔╝
   ╚═╝  ╚═╝╚══════╝╚═╝     ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝ ╚═════╝ ╚═════╝ 
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define ld long double
#define str string
#define ch char
#define db double
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define Bob cout<<"Bob\n";
#define Alice cout<<"Alice\n";
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
const ll INF = 1000000000000000000;
const ll MOD = 998244353;
void solve(){
  ll n;
  cin>>n;
  vector<ll>v(n+1);
  for(int i = 1;i<=n;i++){
    cin>>v[i];
  }
  ll q;
  cin>>q;
  while(q--){
    ll t;
    cin>>t;
    if(t==1){
      for(ll i = 1;i<n;i++){
        if(v[i]>v[i+1]){
          swap(v[i],v[i+1]);
        }
      }
    }
    vector<ll>pref(n+1);
    pref[1]=v[1];
    for(int i = 2;i<=n;i++){
      pref[i]=pref[i-1]+v[i];
    }
    else{
      ll l,r;
      cin>>l>>r;
      cout<<pref[r]-pref[l-1]<<"\n";
    }
  }
}
signed main(){
  ll t=1;
  //cin>>t;
  while(t--){
    solve();
  }
    return 0;
}

Compilation message (stderr)

bubble.cpp: In function 'void solve()':
bubble.cpp:55:5: error: 'else' without a previous 'if'
   55 |     else{
      |     ^~~~