Submission #906365

# Submission time Handle Problem Language Result Execution time Memory
906365 2024-01-14T07:00:32 Z iloveroseanne Po (COCI21_po) C++14
70 / 70
9 ms 1628 KB
/// PARK CHAEYOUNG IS MY LOVE
/// Author: Ngo Ba Van
/// roses_are_rosie
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define MASK(i) (1LL<<i)
#define BIT(x,i) (x&MASK(i))
#define ONBIT(x,i) (x|MASK(i))
#define OFFBIT(x,i) (x&~MASK(i))
#define COUNT(x) (__builtin_popcount(x))
#define RVAN1102 signed main()
using ii=pair<int,int>;
const ll N=2e5+5,M=1e9+7;
ll n,m,res;
stack<int>st;
void nhap()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        while (!st.empty()&&st.top()>x) st.pop();
        if (!st.empty()&&st.top()==x) continue;
        if (x) res++,st.push(x);
    }
    cout<<res;
}
RVAN1102 {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#define task ""
#define task "a"
if(fopen(task".inp","r"))
{
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
}
int t=1;
//cin>>t;
while (t--)
nhap();
}

Compilation message

Main.cpp:36: warning: "task" redefined
   36 | #define task "a"
      | 
Main.cpp:35: note: this is the location of the previous definition
   35 | #define task ""
      | 
Main.cpp: In function 'int main()':
Main.cpp:39:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:40:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     freopen(task".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 5 ms 604 KB Output is correct
6 Correct 9 ms 1628 KB Output is correct
7 Correct 9 ms 1372 KB Output is correct