首页 > 其他分享 >NOI Online #3

NOI Online #3

时间:2022-10-01 06:44:05浏览次数:71  
标签:return NOI int void long Online mod define

普及 最急救助 (红)

模拟

点击查看代码
#include <bits/stdc++.h>
#define ff fflush(stdout)
#define thank puts("I *** thank you ccf"), ff
#define bug(...) fprintf(stderr, __VA_ARGS__)
#define fop(x, l, r) for (int x = l; x <= r; ++x)
#define fio(x, r, l) for (int x = r; x >= l; --x)
#define edg(x, u) for (int x = head[u]; x; x = nxt[x])
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
#define mem(x) memset(x, 0, sizeof x)
const int mod = 998244353, inf = 0x3f3f3f3f3f3f3f3fll;
void ckmax(int &a, int b) { a = max(a, b); }
void ckmin(int &a, int b) { a = min(a, b); }
void amod(int &a, int b) { a += b; if (a >= mod) a -= mod; }
void mmod(int &a, int b) { a = 1ll * a * b % mod; }
void smod(int &a, int b) { a -= b; if (a < 0) a += mod; } 
int amo(int a, int b) { int c = a + b; if (c >= mod) c -= mod; return c; }
int mmo(int a, int b) { return 1ll * a * b % mod; }
int smo(int a, int b) { int c = a - b; if (c < 0) c += mod; return c; }
int Pow(int a, int b) { 
    int ans = 1;
    for (; b; b >>= 1, mmod(a, a)) if (b & 1) mmod(ans, a);
    return ans;
}
inline int read() {
    int x = 0; char c; bool f = 0; 
    while (!isdigit(c = getchar())) if (c == '-') f = 1; 
    do x = (x << 1) + (x << 3) + (c ^ 48); while (isdigit(c = getchar())); 
    return f ? -x : x;
}

const int maxn = 2e2 + 3, maxm = 1e2 + 3;

char str[maxn], name[maxn];
int Max, tot;
char ans[maxn][maxn];

signed main() {
    int n = read();
    fop(i, 1, n) {
        scanf("%s", name + 1);
        scanf("%s", str + 1);
        int res = 0;
        int len = strlen(str + 1);
        fop(i, 1, len - 2) if (str[i] == 's' && str[i + 1] == 'o' && str[i + 2] == 's') ++res;
        if (res > Max) tot = 0, Max = res;
        if (res == Max) memcpy(ans[++tot], name, sizeof name);
    }
    fop(i, 1, tot) printf("%s ", ans[i] + 1);
    printf("\n%lld\n", Max);
}

普及 观星 (橙)

基础 BFS
联通块大小数组一定要记得开 maxn * maxn。。。又在这挂了

点击查看代码
#include <bits/stdc++.h>
#define ff fflush(stdout)
#define thank puts("I *** thank you ccf"), ff
#define bug(...) fprintf(stderr, __VA_ARGS__)
#define fop(x, l, r) for (int x = l; x <= r; ++x)
#define fio(x, r, l) for (int x = r; x >= l; --x)
#define edg(x, u) for (int x = head[u]; x; x = nxt[x])
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
#define mem(x) memset(x, 0, sizeof x)
const int mod = 998244353, inf = 0x3f3f3f3f3f3f3f3fll;
void ckmax(int &a, int b) { a = max(a, b); }
void ckmin(int &a, int b) { a = min(a, b); }
void amod(int &a, int b) { a += b; if (a >= mod) a -= mod; }
void mmod(int &a, int b) { a = 1ll * a * b % mod; }
void smod(int &a, int b) { a -= b; if (a < 0) a += mod; } 
int amo(int a, int b) { int c = a + b; if (c >= mod) c -= mod; return c; }
int mmo(int a, int b) { return 1ll * a * b % mod; }
int smo(int a, int b) { int c = a - b; if (c < 0) c += mod; return c; }
int Pow(int a, int b) { 
    int ans = 1;
    for (; b; b >>= 1, mmod(a, a)) if (b & 1) mmod(ans, a);
    return ans;
}
inline int read() {
    int x = 0; char c; bool f = 0; 
    while (!isdigit(c = getchar())) if (c == '-') f = 1; 
    do x = (x << 1) + (x << 3) + (c ^ 48); while (isdigit(c = getchar())); 
    return f ? -x : x;
}

const int maxn = 1.5e3 + 3, maxm = 1e2 + 3;

int n, m;
int mp[maxn][maxn];

bool Check(int x, int y) { return x > 0 && y > 0 && x <= n && y <= m && mp[x][y] == 3; }

const int dx[] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int dy[] = { 1, 0, -1, 1, -1, 1, 0, -1 };

bool vis[maxn][maxn];
int siz[maxn * maxn], tot;
int t[maxn * maxn];

void DFS(int x, int y) { 
    mp[x][y] = 1, ++siz[tot];
    fop(i, 0, 7) if (Check(x + dx[i], y + dy[i])) DFS(x + dx[i], y + dy[i]); 
}

char str[maxn];

signed main() {
    n = read(), m = read();
    fop(i, 1, n) {
        scanf("%s", str + 1);
        fop(j, 1, m) mp[i][j] = str[j] == '*' ? 3 : 2;
    }
    fop(i, 1, n) fop(j, 1, m) if (mp[i][j] == 3) ++tot, DFS(i, j);
    fop(i, 1, tot) ++t[siz[i]];
    int ans1 = 0, ans2 = 0;
    fop(i, 1, n * n) if (t[i]) ++ans1, ckmax(ans2, t[i] * i);
    printf("%lld %lld\n", ans1, ans2);
}

标签:return,NOI,int,void,long,Online,mod,define
From: https://www.cnblogs.com/eafoo/p/16746690.html

相关文章

  • 图片降噪软件:Topaz DeNoise AI (图像处理)
    TopazDeNoiseAI是一款好用且专业的图片降噪软件。如果你有噪点的相片,可以通过AI智能的方式来处理掉噪点,让照片的噪点降到最低。有了TopazDeNoiseAI处理图片更方便,更简......
  • 【CV算法理解】SORT(Simple Online and Realtime Tracking)跟踪算法理解
      SORT 是一种简单的在线实时多目标跟踪算法。文章要点为:以IoU作为前后帧间目标关系度量指标;利用卡尔曼滤波器预测当前位置;通过匈牙利算法关联检测框到目标;应......
  • 统计射击成绩[(https://www.online1987.com/统计射击比赛成绩/)]
    统计射击成绩[(https://www.online1987.com/统计射击比赛成绩/)]#include<iostream>#include<vector>#include<algorithm>usingnamespacestd;intmain(){ intN=......
  • NOIP冲刺 【图论复习】 图的遍历
    还有两个月就NOIP了我居然还在敲这种东西.........洛谷P5318DFSBFS模版题复习一下DFS:从第一个节点开始搜用vis数组记忆化搜到每一个点时如果没搜过就把他标记......
  • CSP-S 2022进不去NOIP记
    初赛Day0过了。9.26day-OP414报了qbxt腾飞的线上。9.28day-NP414明天放假!9.30day-ZP414这才过了一半,事倒是很多...早上五点多爬起来打游戏,打完之后看手机突......
  • P2671 [NOIP2015 普及组] 求和(洛谷前缀和
    P2671[NOIP2015普及组]求和1//(x+z)*(num[x]+num[z])=2//(x1+x2)*(y1+y2)+(x1+x3)*(y1+y3)+(x2+x3)*(y2+y3)3//=x1*(y1*(n-2)+y1+y2+...+yn)4//+x2*(y2*......
  • P1040 [NOIP2003 提高组] 加分二叉树
    区间dp好题!在更新\(f[i][j]\)时,顺便记录该子树的根节点\(g[i][j]\)。最后递归求解。#include<bits/stdc++.h>usingnamespacestd;classsolve{ public: int......
  • 洛谷 P3193 [HNOI2008]GT考试
    原题链接dp+矩阵加速明天再来写#pragmaGCCoptimize(2)#include<bits/stdc++.h>usingnamespacestd;#definefrfirst#definesesecond#defineet0exit(0);#......
  • 【题解】P3225 [HNOI2012]矿场搭建(割点,dfs)
    【题解】P3225[HNOI2012]矿场搭建割点好题!(因为刚开始没想清楚卡了好久/kk)题目链接P3225[HNOI2012]矿场搭建题意概述给定一张\(n\)条边的无向图,现在要求在其中一......
  • [Ynoi2008] rrusq
    直接做感觉不太行,考虑对于询问\((l,r)\)直接扫描线。将询问\((l,r)\)挂在端点\(l\)上,然后从大到小加入矩阵\(l\)。然后去看\(n\)个点中哪些能够被覆盖,记录\(......