QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#185775#6434. Paimon SortingTJSWWA 0ms3616kbC++141.7kb2023-09-22 16:31:372023-09-22 16:31:37

Judging History

你现在查看的是最新测评结果

  • [2023-09-22 16:31:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2023-09-22 16:31:37]
  • 提交

answer

#include<bits/stdc++.h>

#define int long long
#define endl '\n'
#define mod 998244353
#define ffor(n) for(int i = 0;i < n;++i)


const int N = 2000006; 

using namespace std;

void build_log();
int mv_x[4] = {1,0,-1,0};
int mv_y[4] = {0,1,0,-1};
int year[2][15] = {{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};//1是闰年,0是非闰年
int t;
int m_log2[500005]; // log2(x) + 1
int k;
int n,m;
int h;





signed main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin>>t;
    while(t--)
    {
        cin>>n;
        stack<int>st;
        int sum = 0;
        int a;
        ffor(n)
        {
            cin>>a;
            if(i == 0)
            {
                st.push(a);
            }
            else
            {
                while(!st.empty())
                {
                    if(st.top() <= a)
                    {
                        st.pop();
                    }
                    else
                    {
                        break;
                    }
                }
                if(st.empty())
                {
                    sum += 2;
                    st.push(a);
                }
                else
                {
                    sum += st.size();
                    st.push(a);
                }
            }

            cout<<sum<<' ';
        }

        cout<<endl;
    }
    

    



    return 0;
}





void build_log()
{
    for(int i = 1;i <= n;i++)
    {
        m_log2[i] = m_log2[i-1] + ((1 << m_log2[i-1]) == i);
    }
}




Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3616kb

input:

3
5
2 3 2 1 5
3
1 2 3
1
1

output:

0 2 3 5 7 
0 2 4 
0 

result:

wrong answer 1st lines differ - expected: '0 2 3 5 7', found: '0 2 3 5 7 '