#include#include#include#include#include#include#include#include#include#include

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

C. Main Sequence

系統 2035 0

http://codeforces.com/contest/286/problem/C

思維是關鍵 想通了就感覺簡單了

代碼:

      #include<iostream>

#include<cmath>

#include<cstdio>

#include<string>

#include<cstring>

#include<vector>

#include<stack>

#include<queue>

#include<set>

#include<map>

#include<algorithm>



//#define LL long long

//#define ULL unsigned long long

using namespace std;



const int INF=0x3f3f3f3f;



const int N=1000010;

stack<int>st;

int a[N];

int main()

{

    //freopen("data.in","r",stdin);

    int n;

    while(cin>>n)

    {

        while(!st.empty()) st.pop();

        for(int i=1;i<=n;++i)

        cin>>a[i];

        int m;

        cin>>m;

        while(m--)

        {

            int l;

            cin>>l;

            a[l]=-a[l];

        }

        int l=n;

        while(l>0)

        {

            if(st.empty()||a[l]<0)

            {

                a[l]=-abs(a[l]);

                st.push(l);

            }else

            {

                if(a[l]==(-a[st.top()]))

                st.pop();

                else

                {

                    a[l]=-abs(a[l]);

                    st.push(l);

                }

            }

            --l;

        }

        if(!st.empty())

        cout<<"NO"<<endl;

        else

        {

            cout<<"YES"<<endl;

            for(int i=1;i<=n;++i)

            cout<<a[i]<<" ";

            cout<<endl;

        }

    }

    return 0;

}


    

C. Main Sequence


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 西盟| 庆城县| 贺州市| 汝州市| 姚安县| 隆林| 乌兰察布市| 重庆市| 思南县| 屏东县| 定陶县| 克山县| 凤冈县| 来安县| 高阳县| 遂川县| 墨竹工卡县| 曲阳县| 德惠市| 会理县| 彩票| 青神县| 通化县| 丽水市| 聊城市| 银川市| 连山| 同仁县| 宁夏| 永济市| 临沭县| 邵阳县| 吉水县| 南宫市| 体育| 通州市| 密云县| 隆昌县| 应城市| 东台市| 大新县|