D - Areas on the Cross-Section Diagram Aizu - ALDS1_3_D
2018-01-09 15:58
363 查看
#include <bits/stdc++.h> #define INF 0x3f3f3f3f #define eps 1e-6 typedef long long LL; const double pi = acos(-1.0); const long long mod = 1e9; using namespace std; stack<int> s1; stack<pair<int,int> > s2; vector<int> ans; int main() { //ios_base::sync_with_stdio(false); cin.tie(0); //freopen("int.txt","r",stdin); //freopen("out.txt","w",stdout); string s; cin >> s; int sum = 0; int len = s.size(); for(int i = 0;i < len;i++) { if(s[i] == '\\') s1.push(i); else if(s[i] == '/' && s1.size() > 0) { int j = s1.top();s1.pop(); sum += i - j; int a = i - j; while(s2.size() > 0 && s2.top().first > j) { a += s2.top().second; s2.pop(); } s2.push(make_pair(j,a)); } } while(s2.size() > 0) { ans.push_back(s2.top().second); s2.pop(); } reverse(ans.begin(),ans.end()); cout << sum << endl; cout << ans.size(); for(int i = 0;i < ans.size();i++) cout << ' ' << ans[i]; cout << endl; return 0; }
相关文章推荐
- ALDS1_3_D: Areas on the Cross-Section Diagram
- 第四章 ALDS1_3_D:Areas on the Cross-Section Diagram
- Areas on the Cross-Section Diagram
- Cross-thread operation not valid: Control 'progressBar1' accessed from a thread other than the thread it was created on
- 解决方法!:getImageData on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
- Cross-thread operation not valid: accessed from a thread other than the thread it was created on.
- Memory space manipulating in Java(Section two:Process Memory Model on AIX part three-The Large & Very Large Memory Model)
- On the Android ListView listSelector to solve cross-border issues
- Section 3.3 Home on the Range
- USACO Section 3.3 Home on the Range
- XiaoMi/themis: Themis provides cross-row/cross-table transaction on HBase based on google's percolator.
- USACO-Section3.3 Home on the Range【完全背包】
- usaco Chapter 3 section 3.3 Home on the Range
- USACO Section 3.3 Home on the Range - 优化的BFS..
- USACO-Section 3.3- PROB Home on the Range
- USACO Section 3.3 Home on the Range(dp)
- BackgroundWorker .net 2.0 里微软的多线程组件 学习 Cross-thread operation not valid: Control 'RichTextBox1' accessed from a thread other than the thread it was created on.
- Warning -27077: The "vuser_init" section contains web function(s) when the "Simulate a new user on each iteration" Run-Time Setting is ON.
- 【转发】Cross-thread operation not valid: Control 'progressBar1' accessed from a thread other than the thread it was created on