【題解】Codeforces 1391B. Fix You

【題目敘述】http://codeforces.com/contest/1391/problem/B

#include <iostream>
using namespace std;
 
int t, n, m, ans;
string s;
 
int main() {
    cin >> t;
    while (t--){
        cin >> n >> m;
        ans = 0;
        for (int i = 1; i < n; i++){
            cin >> s;
            if (s[m-1] == 'R') ans++;
        }
        cin >> s;
        for (int i = 0; i < m; i++){
            if (s[i] == 'D') ans++;
        }
        cout << ans << "\n";
    }
}
分享本文 Share with friends