제출 #1197487

#제출 시각아이디문제언어결과실행 시간메모리
1197487nvc2k8Stone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
126 ms14832 KiB
#include <bits/stdc++.h>
#define TASK "stonearranging2"
#define INT_LIM (int) 2147483647
#define LL_LIM (long long) 9223372036854775807
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define BIT(i,x) (((i)>>(x))&1)
#define FOR(i,a,b) for(int i = (a); i<=(b); i++)
#define FORD(i,a,b) for(int i = (a); i>=(b); i--)
#define ll long long
#define pii pair<int,int>
using namespace std;
///------------------------------------------///
int n;
int a[200005];

void inp()
{
    cin >> n;
    FOR(i, 1, n) cin >> a[i];
}

struct item{
    int col, l, r;
};

set<int> dd;
vector<item> f;

void solve()
{
    FOR(i, 1, n)
    {
        if (!dd.count(a[i]))
        {
            dd.insert(a[i]);
            f.pb({a[i], i, i});
        }
        else
        {
            while (f.back().col!=a[i])
            {
                dd.erase(f.back().col);
                f.pop_back();
            }
            f.back().r = i;
        }
    }

    for (auto i:f)
    {
        FOR(j, i.l, i.r) cout << i.col << endl;
    }
}

signed main()
{
    ///--------------------------///
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    if (fopen(TASK".INP","r")!=NULL)
    {
        freopen(TASK".INP","r",stdin);
        freopen(TASK".OUT","w",stdout);
    }
    ///--------------------------///

    int NTEST = 1;
    //cin >> NTEST;

    while (NTEST--)
    {
        inp();
        solve();
    }

    return 0;
}

///------------------------------------------///

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen(TASK".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen(TASK".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...