侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130557 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

CodeForces Round #549 Div.2

2022-12-29 星期四 / 0 评论 / 0 点赞 / 19 阅读 / 5334 字

A. The Doors 代码: #include <bits/stdc++.h>using namespace std;const int maxn = 2e5 + 10;int N;in

... .

A. The Doors

代码:

.

.
#include <bits/stdc++.h>using namespace std;const int maxn = 2e5 + 10;int N;int Zero = 0,One = 0;int a[maxn],b[maxn],suma[maxn],sumb[maxn];int num1,num2,ans;int main() {    scanf("%d",&N);    for(int i = 0; i < N; i ++) {        scanf("%d",&a[i]);        if(a[i] == 1) {            b[i] = 0;            One ++;        }        if(a[i] == 0) {            b[i] = 1;            Zero ++;        }        if(i == 0) suma[i] = a[i],sumb[i] = b[i];        else suma[i] = suma[i - 1] + a[i],sumb[i] = sumb[i - 1] + b[i];    }    for(int i = 0; i < N; i ++) {        if(suma[i] == One) {            num1 = i;            break;        }    }    for(int i = 0; i < N; i ++) {        if(sumb[i] == Zero) {            num2 = i;            break;        }    }    ans = min(num1,num2);    printf("%d/n",ans + 1);    return 0;}
. View Code .

B. Nirvana

代码:

.

.
#include <bits/stdc++.h>using namespace std;int N;int Ans(int x) {    if(x < 10) return max(1,x);    return max((x % 10) * Ans(x / 10),9 * Ans(x / 10 - 1));}int main() {    scanf("%d",&N);    printf("%d/n",Ans(N));    return 0;}
. View Code .

C. Queen

代码:

.

.
#include <bits/stdc++.h>using namespace std;const int maxn = 1e5 + 10;const int inf = 0x3f3f3f3f;int N;int root;int vis[maxn];vector<int> ans;int main() {    scanf("%d",&N);    for(int i = 1; i <= N; i ++) {        int st,col;        scanf("%d%d",&st,&col);        if(col == 0) {            if(st != -1)                vis[st] = 1;            vis[i] = 1;        }    }    for(int i = 1; i <= N; i ++) {        if(vis[i] != 1)            ans.push_back(i);    }    if(ans.size() == 0) printf("-1/n");    else {        sort(ans.begin(),ans.end());        for(int i = 0; i < ans.size(); i ++)            printf("%d%s",ans[i],i != ans.size() - 1 ? " " : "/n");    }    return 0;}
. View Code .

最近是理解能力下降???读题读不清楚???菜是原罪!!!

. .. ...

广告 广告

评论区