#include <bits/stdc++.h> typedef long long ll; const int maxx = 100010; const int inf = 0x3f3f3f3f; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t, n, m; cin >> t; while (t--) { cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (i == 0 && j == 0) cout << "W"; else cout << "B"; } cout << endl; } } return 0; }
#include <bits/stdc++.h> typedef long long ll; const int maxx = 100010; const int inf = 0x3f3f3f3f; using namespace std; int a[maxx], b[maxx]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int ans = inf, cnt = inf; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 1 && ans == inf) ans = i; if (a[i] == -1 && cnt == inf) cnt = i; } int flag = 1; for (int i = 0; i < n; i++) { cin >> b[i]; if (b[i] > a[i] && ans >= i) flag = 0; if (b[i] < a[i] && cnt >= i) flag = 0; } if (flag) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> typedef long long ll; const int maxx = 100010; const int inf = 0x3f3f3f3f; using namespace std; map<ll, ll> mapp; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; cin >> n; mapp[0] = 1; ll m, ans = 0, sum = 0, cnt = 0; for (ll i = 1; i <= n; i++) { cin >> m; sum += m; cnt = max(cnt, mapp[sum]); ans += (i - cnt); mapp[sum] = i + 1; } cout << ans << endl; return 0; }