제출 #781989

#제출 시각아이디문제언어결과실행 시간메모리
781989RecursiveCoStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
193 ms23272 KiB
// CF template, version 3.0 #include <bits/stdc++.h> using namespace std; #define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0) #define getTest int t; cin >> t #define eachTest for (int _var=0;_var<t;_var++) #define get(name) int (name); cin >> (name) #define out(o) cout << (o) #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); } #define sortl(name) sort((name).begin(), (name).end()) #define rev(name) reverse((name).begin(), (name).end()) #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++) #define decision(b) if (b){out("YES");}else{out("NO");} #define int long long signed main() { improvePerformance; //getTest; //eachTest { get(n); getList(n, nums); stack<pair<int, int>> segs; map<int, int> seen; int l = 0; int val = nums[0]; forto(n, i) { if (nums[i] != val) { if (seen.find(val) != seen.end() && seen[val] != 0) { int len = 0; while (segs.top().first != val) len += segs.top().second, seen[segs.top().first]--, segs.pop(); len += segs.top().second; segs.pop(); segs.push({val, len + i - l}); l = i; val = nums[i]; } else { segs.push({val, i - l}); if (seen.find(val) == seen.end()) seen[val] = 1; else seen[val]++; l = i; val = nums[i]; } } } if (seen.find(val) != seen.end() && seen[val] != 0) { int len = 0; while (segs.top().first != val) len += segs.top().second, seen[segs.top().first]--, segs.pop(); len += segs.top().second; segs.pop(); segs.push({val, len + n - l}); } else { segs.push({val, n - l}); } vector<int> res; while (!segs.empty()) { int el = segs.top().first; int cnt = segs.top().second; segs.pop(); forto(cnt, i) res.push_back(el); } rev(res); forto(n, i) { out(res[i]); out("\n"); } //} }

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

Main.cpp: In function 'int main()':
Main.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
Main.cpp:25:9: note: in expansion of macro 'get'
   25 |         get(n);
      |         ^~~
Main.cpp:12:40: warning: unnecessary parentheses in declaration of 'nums' [-Wparentheses]
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                        ^
Main.cpp:26:9: note: in expansion of macro 'getList'
   26 |         getList(n, nums);
      |         ^~~~~~~
Main.cpp:10:23: warning: unnecessary parentheses in declaration of 'a' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
Main.cpp:12:76: note: in expansion of macro 'get'
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                                                            ^~~
Main.cpp:26:9: note: in expansion of macro 'getList'
   26 |         getList(n, nums);
      |         ^~~~~~~
Main.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
Main.cpp:31:9: note: in expansion of macro 'forto'
   31 |         forto(n, i) {
      |         ^~~~~
Main.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
Main.cpp:64:13: note: in expansion of macro 'forto'
   64 |             forto(cnt, i) res.push_back(el);
      |             ^~~~~
Main.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
Main.cpp:67:9: note: in expansion of macro 'forto'
   67 |         forto(n, i) {
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...