Submission #1288658

#TimeUsernameProblemLanguageResultExecution timeMemory
1288658herominhsteveRabbit Carrot (LMIO19_triusis)C++20
Compilation error
0 ms0 KiB
https://usaco.guide/gold/lis#problem-lmio-19-triusis#include <bits/stdc++.h>
#define el '\n'
#define FNAME "LMIO19_triusis"
#define allof(x) x.begin(),x.end()
#define allof1(x) x.begin()+1,x.end()
#define mset(x,n) memset(x,(n),sizeof(x))
using namespace std;
const long long MOD = (long long) 1e9 + 7;
template<class X,class Y> bool minimize(X &a,Y b){ if (a>b) {a=b; return true;} return false;}
template<class X,class Y> bool maximize(X &a,Y b){ if (a<b) {a=b; return true;} return false;}

void setup(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	if (fopen(FNAME".inp","r")){
		freopen(FNAME".inp","r",stdin);
		freopen(FNAME".out","w",stdout);
	}
}

template<typename T>
struct FenwickTree{
    int n;
    vector<T> bit;
    FenwickTree(int N=0){
        n=N;
        if (n>0){
            bit.resize(n+1,0);
        }
    }
    void update(int node,T val){
        while (node<=n){
            maximize(bit[node],val);
            node += (node & -node);
        }
    }
    T getVal(int node){
        T res=0;
        while (node>0){
            maximize(res,bit[node]);
            node -= (node & -node);
        }
        return res;
    }
};

int n,m;
vector<int> a;

void init(){
	cin>>n>>m;
    a.resize(n);
    for (int &x : a) cin>>x;        
}

void sol(){
	vector<int> b;
    vector<int> org;
    org.reserve(n);
    for (int i=0;i<n;i++) 
        if ((i+1) * m >= a[i]) org.push_back((i+1) * m - a[i]);
    
    vector<int> compress(allof(org));
    sort(allof(compress));
    compress.resize(unique(allof(compress))-compress.begin());
    int MAX = compress.size();
    b.resize(org.size());
    
    for (int i=0;i<(int)org.size();i++)
        b[i] = lower_bound(allof(compress),org[i]) - compress.begin() + 1;
    
    FenwickTree<int> bit(MAX);
    for (int x : b){
        bit.update(x,bit.getVal(x) + 1);
    }
    cout<< n - bit.getVal(MAX);
}

int main(){
    setup();
    init();
    sol();
}

Compilation message (stderr)

triusis.cpp:1:1: error: 'https' does not name a type
    1 | https://usaco.guide/gold/lis#problem-lmio-19-triusis#include <bits/stdc++.h>
      | ^~~~~
triusis.cpp: In function 'void setup()':
triusis.cpp:13:5: error: 'ios_base' has not been declared
   13 |     ios_base::sync_with_stdio(0);
      |     ^~~~~~~~
triusis.cpp:14:5: error: 'cin' was not declared in this scope
   14 |     cin.tie(0);cout.tie(0);
      |     ^~~
triusis.cpp:14:16: error: 'cout' was not declared in this scope
   14 |     cin.tie(0);cout.tie(0);
      |                ^~~~
triusis.cpp:15:13: error: 'fopen' was not declared in this scope
   15 |         if (fopen(FNAME".inp","r")){
      |             ^~~~~
triusis.cpp:1:1: note: 'fopen' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
  +++ |+#include <cstdio>
    1 | https://usaco.guide/gold/lis#problem-lmio-19-triusis#include <bits/stdc++.h>
triusis.cpp:16:41: error: 'stdin' was not declared in this scope
   16 |                 freopen(FNAME".inp","r",stdin);
      |                                         ^~~~~
triusis.cpp:16:41: note: 'stdin' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
triusis.cpp:16:17: error: 'freopen' was not declared in this scope
   16 |                 freopen(FNAME".inp","r",stdin);
      |                 ^~~~~~~
triusis.cpp:17:41: error: 'stdout' was not declared in this scope
   17 |                 freopen(FNAME".out","w",stdout);
      |                                         ^~~~~~
triusis.cpp:17:41: note: 'stdout' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
triusis.cpp: At global scope:
triusis.cpp:24:5: error: 'vector' does not name a type
   24 |     vector<T> bit;
      |     ^~~~~~
triusis.cpp: In constructor 'FenwickTree<T>::FenwickTree(int)':
triusis.cpp:28:13: error: 'bit' was not declared in this scope
   28 |             bit.resize(n+1,0);
      |             ^~~
triusis.cpp: In member function 'void FenwickTree<T>::update(int, T)':
triusis.cpp:33:22: error: 'bit' was not declared in this scope
   33 |             maximize(bit[node],val);
      |                      ^~~
triusis.cpp: In member function 'T FenwickTree<T>::getVal(int)':
triusis.cpp:40:26: error: 'bit' was not declared in this scope
   40 |             maximize(res,bit[node]);
      |                          ^~~
triusis.cpp: At global scope:
triusis.cpp:48:1: error: 'vector' does not name a type
   48 | vector<int> a;
      | ^~~~~~
triusis.cpp: In function 'void init()':
triusis.cpp:51:9: error: 'cin' was not declared in this scope
   51 |         cin>>n>>m;
      |         ^~~
triusis.cpp:52:5: error: 'a' was not declared in this scope
   52 |     a.resize(n);
      |     ^
triusis.cpp: In function 'void sol()':
triusis.cpp:57:9: error: 'vector' was not declared in this scope
   57 |         vector<int> b;
      |         ^~~~~~
triusis.cpp:57:16: error: expected primary-expression before 'int'
   57 |         vector<int> b;
      |                ^~~
triusis.cpp:58:12: error: expected primary-expression before 'int'
   58 |     vector<int> org;
      |            ^~~
triusis.cpp:59:5: error: 'org' was not declared in this scope
   59 |     org.reserve(n);
      |     ^~~
triusis.cpp:61:26: error: 'a' was not declared in this scope
   61 |         if ((i+1) * m >= a[i]) org.push_back((i+1) * m - a[i]);
      |                          ^
triusis.cpp:63:12: error: expected primary-expression before 'int'
   63 |     vector<int> compress(allof(org));
      |            ^~~
triusis.cpp:64:16: error: 'compress' was not declared in this scope
   64 |     sort(allof(compress));
      |                ^~~~~~~~
triusis.cpp:4:18: note: in definition of macro 'allof'
    4 | #define allof(x) x.begin(),x.end()
      |                  ^
triusis.cpp:64:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   64 |     sort(allof(compress));
      |     ^~~~
      |     short
triusis.cpp:65:21: error: 'unique' was not declared in this scope
   65 |     compress.resize(unique(allof(compress))-compress.begin());
      |                     ^~~~~~
triusis.cpp:67:5: error: 'b' was not declared in this scope
   67 |     b.resize(org.size());
      |     ^
triusis.cpp:70:16: error: 'lower_bound' was not declared in this scope
   70 |         b[i] = lower_bound(allof(compress),org[i]) - compress.begin() + 1;
      |                ^~~~~~~~~~~
triusis.cpp:76:5: error: 'cout' was not declared in this scope
   76 |     cout<< n - bit.getVal(MAX);
      |     ^~~~