1644E. Expand the Path
生活随笔
收集整理的這篇文章主要介紹了
1644E. Expand the Path
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
E. Expand the Path
一道燈下黑的題目。 我們很顯然知道,要讓每個列的上限最小,下限最大(同理計算行也可以)。 所以圖形應(yīng)該是一個中心對稱圖形 所以空白部分是一個矩形(除了一開始的地方),但是還要加上一開始的部分。 #include <bits/stdc++.h> using namespace std; #define int long long string str; signed main() {int t;cin>>t;while (t--){int n;cin>>n;cin>>str;int len = str.length();int k = 1;while (k<len&&str[k]==str[k-1]) k++;int nx = 0,ny = 0;if (k==len) {cout<<n<<endl;continue;}for (int i = k;i<len;i++){if (str[i]=='R') nx++;else ny++;}int res = 0;res+=k*(n-1);res+=nx*ny;cout<<n*n-res<<endl;} }總結(jié)
以上是生活随笔為你收集整理的1644E. Expand the Path的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Gof 设计模式 完结
- 下一篇: 【原创】MySQL Replay线上流量