제출 #957676

#제출 시각아이디문제언어결과실행 시간메모리
957676VinhLuuStone Arranging 2 (JOI23_ho_t1)C++17
0 / 100
10 ms27232 KiB
#include <bits/stdc++.h> #define int long long #define ll long long #define fi first #define se second #define pb push_back #define all(lmao) lmao.begin(), lmao.end() using namespace std; typedef pair<int,int> pii; typedef tuple<int,int,int> tp; const int N = 1e6 + 5; const int mod = 1e9 + 7; const int oo = 2e18; int n, a[N], b[N], t, p[N]; vector<int> vr[N]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "v" if(fopen(task ".inp","r")){ freopen(task ".inp","r",stdin); freopen(task ".out","w",stdout); } cin >> n; set<int> s; for(int i = 1; i <= n; i ++){ cin >> a[i]; s.insert(a[i]); } for(auto j : s) p[++t] = j; for(int i = 1; i <= n; i ++) a[i] = lower_bound(p + 1, p + t + 1, a[i]) - p; vector<int> cur; for(int i = 1; i <= n; i ++){ if(!vr[a[i]].empty()){ int u = vr[a[i]].back(); int v = i; while(!cur.empty() && cur.back() > u){ int tmp = cur.back(); vr[a[tmp]].pop_back(); cur.pop_back(); } } vr[a[i]].pb(i); cur.pb(i); } for(int i = 1; i <= t; i ++){ if(!vr[p[i]].empty()){ b[vr[p[i]][0]] = p[i]; for(int j = vr[p[i]][0]; j <= vr[p[i]].back(); j ++) b[j] = p[i]; } } for(int i = 1; i <= n; i ++) cout << b[i] << "\n"; }

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

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