제출 #207368

#제출 시각아이디문제언어결과실행 시간메모리
207368balbitRectangles (IOI19_rect)C++14
0 / 100
6 ms504 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define SZ(x) (int)((x).size()) #define ALL(x) x.begin(),x.end() #define pii pair<int, int> #define f first #define s second #ifdef BALBIT #define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<" = ", _do(__VA_ARGS__) template<typename T> void _do(T &&x) {cerr<<x<<endl;} template<typename T, typename ...S> void _do(T &&x, S&&...y) {cerr<<x<<", "; _do(y...);} #define IOS() #else #define IOS() ios::sync_with_stdio(0), cin.tie(0) #define endl '\n' #define bug(...) #endif // BALBIT const int MX = 205; #define REP(i,n) for (int i = 0; i<n; ++i) #define RREP(i,n) for (int i = n-1; i>=0; --i) #define FOR(i,a,b) for (int i = a; i<b; i++) stack<pii> bb; // big boys void add(pii x) { while (!bb.empty() && bb.top().f <= x.f) bb.pop(); bb.push(x); } ll count_rectangles(vector<vector<int> > a) { int n = SZ(a); int m = SZ(a[0]); if (m<=2) return 0; int lb = 0; ll re = 0; add ({a[1][0],0}); add({a[1][1],1}); bb.pop(); vector<int> L(m); for (int i = 0; i<m-1; ++i) { int x = a[1][i]; L[i] = x > a[1][i+1]; } for (int i = 1; i<m-1; ++i) { int x = a[1][i]; bool ok = x < a[0][i] && x < a[2][i]; bool R = ok && x < a[1][i+1]; if (!ok) { while (!bb.empty()) bb.pop(); bb.push({x,i}); } else{ while (!bb.empty() && bb.top().f <= a[1][i+1] ) { if (L[bb.top().s]) re += R; bb.pop(); } if (!bb.empty()) if (L[bb.top().s]) re += R; bb.push({x,i}); } } return re; } #ifdef BALBIT signed main(){ IOS(); ll ro = count_rectangles({{1,1,1,1},{1,0,0,1},{1,1,1,1}}); bug(ro); } #endif

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

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:38:9: warning: unused variable 'n' [-Wunused-variable]
     int n = SZ(a);
         ^
rect.cpp:41:9: warning: unused variable 'lb' [-Wunused-variable]
     int lb = 0;
         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...