Submission #152433

# Submission time Handle Problem Language Result Execution time Memory
152433 2019-09-08T02:26:13 Z 12tqian Bubble Sort 2 (JOI18_bubblesort2) C++14
Compilation error
0 ms 0 KB
#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = 4 * atan(1);

#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define vi vector<int>
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define vpi vector<pair<int, int>>
#define vpd vector<pair<double, double>>
#define pd pair<double, double>

#define f0r(i,a) for(int i=0;i<a;i++)
#define f1r(i,a,b) for(int i=a;i<b;i++)
#define trav(a, x) for (auto& a : x)

template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}

void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
void io(string taskname){
    string fin = taskname + ".in";
    string fout = taskname + ".out";
    const char* FIN = fin.c_str();
    const char* FOUT = fout.c_str();
    freopen(FIN, "r", stdin);
   // freopen(FOUT, "w", stdout);
    fast_io();
}
const int MAX = 5e5 + 5;
set<int> elements;
unordered_map<int, int> um;
int cnt [MAX];
vi cur;
int n, q;
vector<int> a, v, x;
inline int upd(int loc, int val){
    if(val == cur[loc]){
        f0r(i, n){
            mx = max(mx, cnt[i]);
        }
        return mx;
    }
    cnt[loc] = 0;
    f0r(i, loc){
        if(cur[i]>val){
            cnt[loc]++;
        }
    }
    f1r(i, loc+1, n){
        if(val>cur[i]){
            if(cur[loc] >cur[i]) continue;
            cnt[i]++;
        }
        else{
            if(cur[loc]>cur[i]){
                cnt[i]--;
            }
        }
    }
    cur[loc] = val;
    int mx = 0;
    f0r(i, n){
        mx = max(mx, cnt[i]);
    }
    return mx;
}
vi countScans(vi a1, vi x1, vi v1){
    a = a1;
    x = x1;
    v = v1;
    n = sz(a);
    q = sz(x);
    f0r(i, n) elements.insert(a[i]);
    f0r(i, q) elements.insert(v[i]);
    int num = 0;
    for(auto e: elements){
        um[e] = num;
        num++;
    }
    f0r(i, n) a[i] = um[a[i]];
    f0r(i, q) v[i] = um[v[i]];
    f0r(i, n) cur.eb(0);
    f0r(i, n){
        upd(i, a[i]);
    }
    vi ret;
    f0r(i, q){
        ret.eb(upd(x[i], v[i]));
    }
    return ret;
}


/*
int main(){
    int n, q;
    cin >> n >> q;
    vi v1, v2, v3;
    f0r(i, n){
        int x;
        cin >> x;
        v1.eb(x);
    }
    f0r(i, q){
        int x;
        cin >> x;
        v2.eb(x);
    }
    f0r(i, q){
        int x;
        cin >> x;
        v3.eb(x);
    }
    cout << countScans(v1, v2, v3) << endl;
    return 0;
}*/

Compilation message

bubblesort2.cpp:1:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/stack:200000000")
 
bubblesort2.cpp: In function 'void io(std::__cxx11::string)':
bubblesort2.cpp:53:17: warning: unused variable 'FOUT' [-Wunused-variable]
     const char* FOUT = fout.c_str();
                 ^~~~
bubblesort2.cpp: In function 'int upd(int, int)':
bubblesort2.cpp:68:13: error: 'mx' was not declared in this scope
             mx = max(mx, cnt[i]);
             ^~
bubblesort2.cpp:68:13: note: suggested alternative: 'x'
             mx = max(mx, cnt[i]);
             ^~
             x
bubblesort2.cpp:70:16: error: 'mx' was not declared in this scope
         return mx;
                ^~
bubblesort2.cpp:70:16: note: suggested alternative: 'x'
         return mx;
                ^~
                x
bubblesort2.cpp: In function 'void io(std::__cxx11::string)':
bubblesort2.cpp:54:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen(FIN, "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~