A:1191-A
这个简单,完成仔细阅读即可做题,无非俩种情况
B:1191-B
这个也是分类就三种情况
0:三个相同的 || 三个连续的
1:俩个相同的 || abs(a-b) <= 2
2:三个八杆子打不着的
我写的代码是个锤子,判断三个连续的出现了问题
题解代码:
枚举判断,读入处理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| #include <bits/stdc++.h> using namespace std; int main() { int idx[257] = {}, c[3][9] = {}, ans = 2; idx['m'] = 1; idx['p'] = 2; idx['s'] = 3; for(int i = 0; i < 3; ++i) { char buf[3]; scanf("%s", buf); ++c[idx[buf[1]] - 1][buf[0] - '1']; } for(int i = 0; i < 3; ++i) for(int j = 0; j < 9; ++j) { ans = min(ans, 3 - c[i][j]); if(j + 2 < 9) ans = min(ans, 3 - !!c[i][j] - !!c[i][j + 1] - !!c[i][j + 2]); } printf("%d\n", ans); return 0; }
|
C:1191-C/1190-A
一页一页的删除元素,记住删除了几个元素
(用原坐标-删除数量 )/ 每页的元素 = 现在的页数;
算出现在页数的右坐标,while找到所有小于等于右坐标未删除元素
删去,ans++,重复此过程
注意数据范围Long Long
ac代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| LL T,N,M;
vector<LL> a;
int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
LL k; cin >> N >> M >> k; LL x; for(int i = 0;i < M;i++) { cin >> x; a.push_back(x); } LL ans = 0; LL pianyi = 0; LL page = k; for(int i = 0;i < M;i++) { LL n = (a[i] - pianyi) / k; if((a[i] - pianyi) % k == 0) { pianyi++; ans++; } else { page = (n+1)*k; int j =i+1; for(;j < M;j++) { if((a[j] - pianyi) > page) break; } ans++; pianyi += j - i; i = j-1; } } cout << ans <<endl; return 0; }
|
D: 1190-B/1191-D
如果s起手不会输的话,那么最终石头的数量一定会是0 - n-1的一个序列,然后下一个人移动完就会输
首先我先去除掉s起手就会输的情况
- 数量为n的堆数超过了2
- 数量为n的堆数等于2,但是n-1有一堆
- 数量为0的堆超过了2
- 数量为m,n的堆大于1
当堆不满足上述的条件之后,经过重新排序,一定可以变成一个上升序列
为了使元素在减小的过程中不会相等后面的元素只能减小到比前一个元素大一位
所以最后就会形成0 - n-1的一个序列
我们只需要计算出从原序列到最后的等差序列走了多少步
然后奇偶讨论就可以
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| LL T,N,M;
map<int,int> a; vector<int> b;
int mycoutans(bool flag) { if(flag) cout << "cslnb" <<endl; else cout << "sjfnb" << endl; }
int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> N; int x; for(int i = 0;i < N;i++) { cin >>x; a[x]++; b.push_back(x); } if(a.find(0) != a.end()) { if(a[0] > 1) { mycoutans(1); return 0; } } int cnt = 0; for(auto it = a.begin();it != a.end();it++) { if(it->second > 2) { mycoutans(1); return 0; } if(it -> second > 1) { cnt++; if(cnt == 2) { mycoutans(1); return 0; } if(a.find(it->first - 1) != a.end()) { mycoutans(1); return 0; } } } LL sum = 0; LL cmt = 0; sort(b.begin(),b.end()); for(int i = 0;i < N;i++) { sum += b[i] + cmt; cmt++; } if(sum % 2 == 0) mycoutans(1); else mycoutans(0); return 0; }
|