A AtCoder abc315_a tcdr 代码源自 cccyyymmm||草履虫万岁 程彦铭 如有题解疑问可咨询该同学
#include<bits/stdc++.h>
using namespace std;
int main(){
char a[1000];
scanf("%s",a+1);
for(int i=1;i<=strlen(a+1);i++){
if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'){
}
else{
cout<<a[i];
}
}
return 0;
}B AtCoder abc310_a Order Something Else 代码源自 fangchengyu (方呈昱) 如有题解疑问可咨询该同学
#include<bits/stdc++.h>
using namespace std;
int n,h,x,a;
int main(){
cin>>n>>h>>x;
for(int i=1;i<=n;i++){
cin>>a;
if(a+h>=x){
cout<<i;
return 0;
}
}
return 0;
}C AtCoder abc317_a Potions 代码源自 chenminghaoXXX’s 陈明浩 如有题解疑问可咨询该同学
#include<bits/stdc++.h>
using namespace std;
int a[111],n,x,h,as;
int main(){
cin>>n>>h>>x;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
if(h+a[i]>=x){
cout<<i;
return 0;
}
}
return 0;
}D AtCoder abc315_b The Middle Day 代码源自 cjz_YunLuo (沄洛) 陈俊喆 如有题解疑问可咨询该同学
#include<bits/stdc++.h>
using namespace std;
int n,m;
struct node{
int p,c,f[105];
}a[105];
bool cmp(node x,node y){
if(x.p==y.p) return x.c>y.c;
return x.p<y.p;
}
int main(){
scanf("%d %d",&n,&m);
for(int i=1,c;i<=n;i++){
scanf("%d %d",&a[i].p,&c);a[i].c=c;
for(int l=1,k;l<=c;l++){
scanf("%d",&k);
a[i].f[k]++;
}
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;i++){
for(int l=i+1;l<=n;l++){
bool flag=true,f=false;
for(int j=1;j<=m;j++){
if(a[l].f[j]>a[i].f[j]){
flag=false;
break;
}
if(a[i].f[j]>a[l].f[j]) f=true;
}
if(a[i].p==a[l].p) flag&=f;
if(flag){
printf("Yes");
// cout<<"\n"<<a[i].p<<" "<<a[i].c<<"\n"<<a[l].p<<" "<<a[l].c;
return 0;
}
}
}
printf("No");
return 0;
} E AtCoder abc310_b Strictly Superior 代码源自 cccyyymmm||草履虫万岁 程彦铭 如有题解疑问可咨询该同学
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const LL N = 1e2 + 10, MOD = 998244353;
bitset<101>a[N];
int p[N];
void solve()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1, c; i <= n; ++i)
{
scanf("%d%d", &p[i], &c);
for (int j = 1, x; j <= c; ++j)
{
scanf("%d", &x);
a[i][x] = 1;
}
}
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= n; ++j)if (i != j)
{
if (p[i] <= p[j])
{
bitset<101>t = a[i] & a[j];
if (t == a[j] && (p[i] < p[j] || t != a[i]))
{
printf("Yes\n");
return;
}
}
}
}
printf("No\n");
}
int main()
{
int T = 1;
while (T--)
{
solve();
}
return 0;
}F AtCoder abc315_c Flavors 代码源自 CEFqwq’s 许嘉懿 如有题解疑问可咨询该同学
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define R(n) cin >> n
#define W(n) cout << n
int n;
struct node{
int f, s;
}a[314159];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
R(n);
fr (i, 1, n){
R(a[i].f);
R(a[i].s);
}
sort(a + 1, a + 1 + n, [](node a, node b){return a.s > b.s;});
int ns = a[1].s, ans = 0;
fr (i, 2, n){
int gx = (a[i].f == a[1].f ? a[i].s / 2 : a[i].s);
ans = max(ans, ns + gx);
}
cout << ans;
}H AtCoder abc315_e Prerequisites 代码源自 CEFqwq’s 许嘉懿 如有题解疑问可咨询该同学
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define R(n) cin >> n
#define W(n) cout << n
int n, c[200005], in[200005];
vector<int> G[200005];
priority_queue<int> q;
stack<int> s;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
R(n);
fr (i, 1, n){
R(c[i]);
fr (j, 1, c[i]){
int x;
R(x);
G[i].push_back(x);
in[x]++;
}
}
fr (i, 1, n)
if (!in[i])
q.push(i);
while (!q.empty()){
int u = q.top();
s.push(u);
q.pop();
for (auto v : G[u]){
in[v]--;
if (!in[v])
q.push(v);
}
}
while (1){
int u = s.top();
if (u == 1)
return 0;
cout << u << " ";
s.pop();
}
}代码源自 (铃声掌控者)
#include<bits/stdc++.h>
using namespace std;
int n,c,cnt,head[200005],mark[200005];
struct node{
int to,w,nxt;
}edge[200005];
void add_edge(int u,int v,int w){
edge[cnt].to=v;
edge[cnt].w=w;
edge[cnt].nxt=head[u];
head[u]=cnt++;
}
void dfs(int no){
if(head[no]==-1){
cout<<no<<" ";return ;
}
for(int j=head[no];j!=-1;j=edge[j].nxt){
if(mark[edge[j].to]==0){
mark[edge[j].to]=1;
dfs(edge[j].to);
}
}
if(no!=1) cout<<no<<" ";
}
int main(){
cin>>n;
memset(head,-1,sizeof(head));
for(int i=1;i<=n;i++){
cin>>c;
while(c--){
int a;
cin>>a;
add_edge(i,a,1);
}
}
dfs(1);
return 0;
} J AtCoder abc315_g Ai + Bj + Ck = X (1 <= i, j, k <= N) 代码源自 cccyyymmm||草履虫万岁 程彦铭 如有题解疑问可咨询该同学 扩展GCD模板题
#include<bits/stdc++.h>
using namespace std;
#define int __int128
#define inf_db 127
#define ls id << 1
#define rs id << 1 | 1
#define re register
#define endl '\n'
typedef pair <int,int> pii;
int n,a,b,c,k,x,y,Ga,Gb,ans,nx,ny;
long long N,A,B,C,K,ANS;
inline int Exgcd(int a,int b,int &x,int &y)
{
if(b == 0){x = 1,y = 0;return a;}
int d = Exgcd(b,a % b,x,y);
int z = x;x = y,y = z - (a / b) * y;
return d;
}
signed main()
{
scanf("%lld%lld%lld%lld%lld",&N,&A,&B,&C,&K);
n = N,a = A,b = B,c = C,k = K;
int d = Exgcd(a,b,x,y);
Ga = b / d,Gb = a / d;
for(re long long i = 1;i <= n && k > c;i++)
{
k -= c;
if(k % d != 0) continue;
int G = k / d,minx,maxx;
nx = x * G,ny = y * G;
nx = (nx % Ga + Ga - 1) % Ga + 1;
if(ny <= n) ny = n - (n - ny) % Gb;
else ny = ny - ((ny - n - 1) / Gb + 1) * Gb;
minx = max(nx,(k - ny * b) / a);
ny = (ny % Gb + Gb - 1) % Gb + 1;
if(nx <= n) nx = n - (n - nx) % Ga;
else nx = nx - ((nx - n - 1) / Ga + 1) * Ga;
maxx = min(nx,(k - ny * b) / a);
if(maxx >= minx) ans += (maxx - minx) / Ga + 1;
}
ANS = ans;
printf("%lld",ANS);
return 0;
}