A FairGame
//Fair Game//一道裸的模拟题而已//二十分钟了。。。mdzz//虽然英文蛋疼#include #include
B
//第二题反而开始灌水了,十分钟都没有就搞定了??,结果WA。。。//两个智障BUG改了10分钟,我还差点写了对拍#include #include #include #include using namespace std;set Set;int main(){ int n; cin>>n; string s; cin>>s; int t = 0, ans = 0; for(int i = 0; i < n; i++){ //BUG1QAQ字符串为什么会从1开始呢。。。 if(isupper(s[i])){ ans = max(ans, t); t = 0; Set.clear();} else if(islower(s[i])){ if(Set.count(s[i]))continue; else { Set.insert(s[i]); t++; } } } //BUG2出来的时候要更新,万一没有大写字母呢 ans = max(ans, t); cout< <<"\n"; return 0;}
C
//WA//数据范围有点方了,先试试模拟会不会T, 专业打表写了半小时我去。。。//打表到这份上也是没谁了,然而还是炸了,,第六个点就WA,,然而,真的,没法改了。。。#include using namespace std;int main(){ int a, b, f, k; cin>>a>>b>>f>>k; int lx = f, rx = a-f; int ln = f*2, rn = (a-f)*2; int dir = 0, res = b-lx;//dir为0朝右边, int i = 0, ans = 0; if(res < 0){ cout<<"-1\n"; return 0; } while(i < k-1){ if(res < 0){ cout<<"-1\n"; return 0; } if(!dir){ if(res >= rn){ dir = 1; res -= rn; i++; continue; }else{ dir = 1; res = b-rn; i++; ans++; } if(res < 0){ cout<<"-1\n"; return 0; } } else{ if(res >= ln){ dir = 0; res -= ln; i++; continue; }else{ dir = 0; res=b-ln; i++; ans++; } if(res < 0){ cout<<-1<<"\n"; return 0; } } } if(res < 0){ cout<<"-1\n"; return 0; } if(i == k-1){ if(!dir && res < rx)ans++; if(dir && res < lx)ans++; } if(res < 0){ cout<<"-1\n"; return 0; } cout< <<"\n"; return 0;}
//AC//正确的打表姿势#include using namespace std;int main(){ int a, b, f, k; cin>>a>>b>>f>>k; int dir = 0, res = b-f, ans = 0; if(res < 0){ cout<<-1<<"\n"; return 0; } while(k-->0){ int l; if(!dir){ if(k == 0)l = a-f; else l = (a-f)<<1; }else{ if(k == 0)l = f; else l = f<<1; } if(res < l){ ans++; res = b; } res -= l; dir = !dir; if(res < 0){ cout<<-1<<"\n"; return 0; } } cout< <<"\n"; return 0;}
D
//WA//贪心失败。。sort失败,,,现在手写排序已经来不及了。。。#include #include #include #define maxn 200010using namespace std;set s;int a[maxn], b[maxn], c[maxn];//b记录值i第一次在a中出现的位置bool cmp(int a, int b){ //if(c[a]&&c[b]) return a < b;}int main(){ int n; cin>>n; int t, ans = 0, minv = 1; for(int i = 1; i <= n; i++){ cin>>t; a[i] = t; if(!s.count(t)){ s.insert(t); b[t] = i; continue; } else{ if(minv >= *s.begin()){ for(set ::iterator it = s.begin()++; it != s.end(); it++){ if(minv < *it)break; else minv = (*it)+1; } } a[b[t]] = minv; c[minv] = 1; b[t] = i; minv++; ans++; } } sort(a+1,a+n+1, cmp); cout< <<"\n"; for(int i = 1; i <= n; i++) cout< <<" "; cout<<"\n"; return 0;}