Submission #774782

#TimeUsernameProblemLanguageResultExecution timeMemory
774782vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
0 / 100
8 ms5204 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n, x; map<int,int>mp; int a[200001], c[200001], b[200001], cnt; ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i=0;i<n;i++) { cin >> a[i]; } for(int i=n-1;i>=0;i++) { if(mp[a[i]] == 0) { mp[a[i]] = i; c[i] = i; b[i] = i; } else { c[i] = i; b[i] = mp[a[i]]; mp[a[i]] = i; } } int p = 0; bool ck = false; while(p < n) { cnt = b[p] - c[p] + 1; if(!ck) { for(int i=1;i<=cnt;i++) { cout << a[p] << endl; } } else { for(int i=1;i<=cnt-1;i++) { cout << a[p] << endl; } } p += cnt; if(cnt > 1) { p -= 1; ck = 1; } else { ck = false; } } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:5:9: warning: unused variable 'x' [-Wunused-variable]
    5 |  int n, x;
      |         ^
Main.cpp:34:12: warning: 'b[p]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |   cnt = b[p] - c[p] + 1;
      |         ~~~^
Main.cpp:34:19: warning: 'c[p]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |   cnt = b[p] - c[p] + 1;
      |                ~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...