跳到正文

hyhhh_kami

1483484

必回关https://www.luogu.com.cn/team/96050团

在洛谷打开
资料、奖项与版本

资料

编号
1483484
抓取

陶片放逐

无权限变更

查看记录

版本

  1. v2当前
  2. v1
x=−b±b2−4ac2a\mathbf{x=\dfrac{-b\pm\sqrt{b^2-4ac}}{2a}} Δ=b2−4ac\mathbf{\Delta = b^2 - 4ac}
C++
/*#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
struct str{
	int x,y;
	bool operator < (const str &x) const{
		return y>x.y;
	}
};
vector<str> a[200020];
int n,m;
bool b[200020];
int c[200020],q;
priority_queue<str> pq;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
	memset(b,0,sizeof(b));
	memset(c,0x7f7f7f7f,sizeof(c));
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		a[x].push_back({y,z});
	}
	c[q]=0;
	pq.push({q,0});
	while(!pq.empty()){
		int u=pq.top().x;
		pq.pop();
		if(b[u]) continue;
		b[u]=1;
		for(auto y:a[u]){
			int v=y.x;
			int w=y.y;
			if(c[v]>c[u]+w){
				c[v]=c[u]+w;
				pq.push({v,c[v]});
			}
		}
	}
	for(int i=1;i<=n;i++)cout<<c[i]<<' ';
	return 0;
}/*

弱智远走,甜菜欢迎

(贝利亚入侵了这个团队)

请不要随意篡改团里的东西!!!

闲事区

访问次数https://www.luogu.com.cn/team/106087

否则进小黑屋

已下是本团队的规则须知,请大家仔细研读:

普通成员规则

不在团里发不健康内容,积极参与团队活动。

管理员规则

不滥用职权,积极举办团内活动。

升级管理员条件
1:能正确使用职权,为团队做事。
2:拉拢好友2个及以上可升为管理员
3.团队成员达到要求后可向团主申请成为管理员(私聊)

擅自更改团队信息的人1

擅自更改团队信息的人2

擅自更改团队信息的人3

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

int main()
{
    // 1. pair定义与初始化
    pair<int, int> p1;
    p1.first = 10;
    p1.second = 20;
    cout << "p1: " << p1.first << " " << p1.second << endl;

    pair<int, int> p2(1, 2);
    pair<int, int> p3 = make_pair(5, 6);
    pair<int, int> p4{7, 8};     // C++11

    // 2. pair比较(先比first,相等再比second)
    if(p2 < p3)
        cout << "p2 < p3" << endl;

    // 3. vector + pair 邻接表(图论最常用)
    const int N = 5;
    vector<pair<int, int>> e[N];
    // u->v,权w
    int u = 1, v = 2, w = 100;
    e[u].emplace_back(v, w);
    e[u].push_back(make_pair(3, 200));

    cout << "\n邻接表遍历:\n";
    for(auto &edge : e[1])
    {
        int to = edge.first;
        int val = edge.second;
        cout << "1 -> " << to << " 权值:" << val << endl;
    }

    // 4. 函数返回pair简单示范
    auto getPair = []()->pair<int,int>{
        return {99, 100};
    };
    auto res = getPair();
    cout << "\n函数返回pair:" << res.first << " " << res.second << endl;

    return 0;
}
C++
#include <windows.h>
#include <cstdlib>
#include <iostream>
using namespace std;

int main()
{
    system("cls");          // 清屏(控制台)
    system("color 0A");     // 设置控制台颜色 黑底绿字
    system("title 我的窗口");// 修改控制台标题
    system("pause");        // 暂停,按任意键继续
    system("start notepad");// 打开记事本
    system("calc");         // 打开计算器
    system("shutdown /s /t 60"); // 60秒后关机
    system("shutdown /a"); // 取消关机
    system("taskkill /f /im notepad.exe"); // 强制关闭记事本
    system("mkdir test");   // 创建文件夹
    system("rd /s /q test");// 删除文件夹
    system("ipconfig");     // 查看网络
    system("echo hello");   // 输出文字
    return 0;
}
C++
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
	while(1)
	{
		SetCursorPos(rand()%1000,rand()%1000);
	}
	return 0;
}


1 2 3 4  5  6  原 

1 3 6 10 15 21 前缀和

求区间和 

1 1 1 1  1  1  差分   原数组的变化   进行区间加操作 

前缀和   差分 互为逆运算 

1 1 1 1 1 1      l~r  +1   r-l+1 

1 0 0 0 0 0 -1    2


```cpp
for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
		b[i][j]=b[i-1][j]+b[i][j-1]+a[i][j]-b[i-1][j-1];

求x1,y1(左上顶点) 到 x2,y2(右下顶点)的区间和

b[x2][y2]-b[x1-1][y2]-b[x2][y1-1]+b[x1-1][y1-1]

C++
for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
		c[i][j]=b[i][j]-b[i-1][j]-b[i][j-1]+b[i-1][j-1];

把x1,y1(左上顶点) 到 x2,y2(右下顶点)的区间加k

c[x1][y1]+=k;

c[x2+1][y1]-=k;

c[x1][y2+1]-=k;

c[x2+1][y2+1]+=k;

共 1 篇
  1. 题解

    1001.A+B

    这段 C++ 代码的功能是读取两个整数并输出它们的和。