跳到正文

闲话

Temp

Everything_约 3 分钟
原文

这是 2025年10月18日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2024年3月23日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 3 分钟

版本

  1. v2当前
  2. v1

同学借鉴版↓

C++
#include<bits/stdc++.h>
using namespace std;
int r, c, a[105][105], m[105][105], maxx = 1000000, k, ans;
char t;
int main()
{
    cin >> r >> c >> k;
    for(int i = 1; i <= r; i++)
    {
        for(int j = 1; j <= c; j++)
        {
            cin >> t;
            if(t == 'o') a[i][j] = 1;
        }
    }
    for(int i = 1; i <= r; i++)
		for(int j = 1; j <= c; j++)
			m[i][j] = m[i - 1][j] + m[i][j - 1] - m[i - 1][j - 1] + a[i][j];
    for(int i = 1; i <= r; i++)
    {
        for(int j = 1; j <= c; j++)
        {
            for(int x = i; x <= r; x++)
            {
                for(int y = j; y <= c; y++)
                {
                    if(m[x][y] - m[i - 1][y] - m[x][j - 1] + m[i - 1][j - 1] == k)
                    {
                        ans = (i - 1) + (j - 1) + (r - x) + (c - y);
                        ans += min((i - 1), (r - x));
                        ans += min((j - 1), (c - y));
                        maxx = min(maxx, ans);
                    }
                }
            }
        }
    }
    if(maxx == 1000000) maxx = -1;
    cout << maxx;
    return 0;
}

陈曦予路过(~ ̄▽ ̄)~

点个赞吧~TAT

Code 暂存处👇

C++
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 5e4 + 5; 
long long n, d1[MAXN], d2[MAXN];
struct whole
{
	long long to, w;
};
vector <whole> edge[MAXN << 1];
void dfs1(long long u, long long f)
{
	for(int i = 0; i < edge[u].size(); i++)
	{
		long long to
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 1; i < n; i++)
	{
		long long u, v, w;
		cin >> u >> v >> w;
		edge[u].push_back((whole) {v, w});
		edge[v].push_back((whole) {u, w});
	}
	
	return 0;
}