제출 #1281263

#제출 시각아이디문제언어결과실행 시간메모리
1281263tunademayoStone Arranging 2 (JOI23_ho_t1)C++20
0 / 100
1 ms572 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second const bool Multitest = 0; const int N = 2e5 + 10; int cnt[N]; stack<pair<int, int>> t; int a[N], n; void work() { cin >> n; for(int i = 1 ; i <= n ; i++) { cin >> a[i]; } for(int i = 1 ; i <= n ; i++) { cerr << i << '\n'; if(cnt[a[i]] == 0) { cnt[a[i]] = 1; } else { while(true) { pair<int, int> x = t.top(); t.pop(); if(x.fi == a[i]) { break; } else { cnt[x.fi] = 0; } } } cnt[a[i]]++; t.push({a[i], cnt[a[i]]}); } int last = n; while(!t.empty()) { pair<int, int> x = t.top(); t.pop(); int tmp = last; last -= x.se; for(int i = last + 1 ; i <= tmp ; i++) a[i] = x.fi; } for(int i = 1 ; i <= n ; i++) cout << a[i] << ' '; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if(fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } int q = 1; if(Multitest) cin >> q; while(q--) work(); }

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

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