#include<bits/stdc++.h> usingnamespace std; intmain(){ int n; cin >> n; string s; cin >> s; int a = s.find('|'); int b = s.find('|',a + 1); int c = s.find('*'); if(c > a && c < b) cout << "in"; else cout << "out"; return0; }
B - Trick Taking
题目大意
给定n个人的卡片,颜色为 c[i] ,数字为 r[i] 。
如果其中有颜色为 T 的牌,则该颜色中数字最大的卡片对应的人赢。如果没有,则颜色为第一个人的卡牌颜( 即c[0] )中数字最大的卡片对应的人赢。问谁赢。
#include<bits/stdc++.h> usingnamespace std; constint N = 2*1e5*10;; int c[N],r[N]; int n, t; voidsolve(){ int res1 = 0; bool flag = false; for (int i = 0; i < n; i++) { if (c[i] == t) { res1 = max(res1, r[i]); flag = true; } } if (flag) { for (int i = 0; i < n; i++) { if (res1 == r[i]) { cout << i + 1; break; } } } else { int res2 = r[0]; for (int i = 1; i < n; i++) { if (c[i] == c[0]) { res2 = max(res2, r[i]); } } for (int i = 0; i < n; i++) { if (res2 == r[i]) { cout << i + 1; break; } } } } intmain(){ cin >> n >> t; for(int i = 0; i < n; i++) cin >> c[i]; for(int i = 0; i < n; i++) cin >> r[i]; solve(); return0; }
N = int(input()) S = input() S = S + '-' ans = -1 j = -1 for i inrange(N+1) : if S[i] == '-' : l = i - j - 1 if l > 0and (j >= 0or i < N) : ans = max(ans, l) j = i print(ans)
#include<bits/stdc++.h> using i64 = longlong; intmain(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N; std::cin >> N; int l = 1, r = N; while (l < r - 1) { int m = (l + r) / 2; std::cout << "? " << m << std::endl; int res; std::cin >> res; if (res == 1) { r = m; } else { l = m; } } std::cout << "! " << l << std::endl; return0; }