快速读入板子

本文介绍了一种高效的段树实现方法,通过自定义输入输出流优化读写速度,并使用递归方式完成区间修改和查询操作。适用于大量数据处理及快速响应需求。
//#include <bits/stdc++.h>
#include<vector>
#include<iostream>
#include<string.h>

using namespace std;
//#include <bits/stdc++.h>
using namespace std;
int n, t[5000010 * 4];
namespace io {
    const int SIZE = (1 << 21) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
    // getchar
#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
    // print the remaining part
    inline void flush () {
        fwrite (obuf, 1, oS - obuf, stdout);
        oS = obuf;
    }
    // putchar
    inline void putc (char x) {
        *oS ++ = x;
        if (oS == oT) flush ();
    }
    template<typename A>
    inline bool read (A &x) {
        for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;else if(c==EOF)return 0;
        for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
        return 1;
    }
    template<typename A>
    inline bool write (A x) {
        if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
        while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
        while (qr) putc (qu[qr --]);
        return 0;
    }
    inline bool write (char x) {
        putc(x);
        return 0;
    }
    //no need to call flush at the end manually!
    struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
void up(int x) {
    t[x] = t[x << 1] + t[x << 1 | 1];
}
void modify(int x, int l, int r, int pos, int val) {
    if (l == r) {
        t[x] = val;
        return;
    }
    int mid = l + r >> 1;
    if (pos <= mid) modify(x << 1, l, mid, pos, val);
    else modify(x << 1 | 1, mid + 1, r, pos, val);
    up(x);
}
int query(int x, int l, int r) {
    if (l == r) return t[x];
    int mid = l + r >> 1;
    if (t[x << 1] == (mid - l + 1)) return t[x << 1] + query(x << 1 | 1, mid + 1, r);
    return query(x << 1, l, mid);
}
using io :: read;
using io :: putc;
using io :: write;
char buf[16 * 1024 * 1024 + 5]; // 10 MiB Buffer
int curpos = 0, iseof;
int nextInt()
{
    int ret = 0;
    if (iseof) return 0;
    while (!('0' <= buf[curpos] && buf[curpos] <= '9'))
    {
        if (buf[curpos] == 0)
        {
            if (fgets(buf, 16 * 1024 * 1024, stdin) == NULL) iseof = true;
            curpos = 0;
            continue;
        }
        curpos++;
    }
    int flg = 0;
    if (curpos && buf[curpos - 1] == '-') flg = -1;
    else flg = 1;
    while ('0' <= buf[curpos] && buf[curpos] <= '9')
    {
        ret = ret * 10 + (buf[curpos] - '0');
        curpos++;
    }
    return ret * flg;
}
int main() {
//    scanf("%d", &n);
//    read(n);
    n=nextInt();
    for (int i = 1; i <= n; i++) {
        int opt, x;
        opt=nextInt();
        x=nextInt();
//        read(opt), read(x);
        if (opt == 1) modify(1, 1, n, x, 1);
        else {
            modify(1, 1, n, x, 1);
            write(query(1, 1, n) + 1);
            putc('\n');
            modify(1, 1, n, x, 0);
        }
    }
}

C:\Users\kiki>ssh root@192.168.10.122 The authenticity of host '192.168.10.122 (192.168.10.122)' can't be established. ED25519 key fingerprint is SHA256:3aSXSmZgEArfV83eQbHRW5adsYXZ/H/JtHC7GuVJqBI. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.10.122' (ED25519) to the list of known hosts. root@192.168.10.122's password: Permission denied, please try again. root@192.168.10.122's password: Welcome to Linaro 14.04 (GNU/Linux 4.14.0-gb6e379910a11-dirty armv7l) * Documentation: https://wiki.analog.com/ https://ez.analog.com/ Last login: Thu Jan 1 00:00:13 1970 root@analog:~# ls openwifi root@analog:~# cd openwifi/ root@analog:~/openwifi# ./wgd.sh usage: Script for load (or download+load) different driver and FPGA img without rebooting no argument: Load .ko driver files and FPGA img (if system_top.bit.bin exist) in current dir with test_mode=0. 1st argument: If it is a NUMBER, it will be assigned to test_mode. Then load everything from current dir. 1st argument: If it is a string called "remote", it will download driver/FPGA and load everything. - 2nd argument (if exist) is the target directory name for downloading and reloading - 3rd argument (if exist) is the value for test_mode 1st argument: neither NUMBER nor "remote" nor a .tar.gz file, it is regarded as a directory and load everything from it. - 2nd argument (if exist) is the value for test_mode 1st argument: a .tar.gz file, it will be unpacked then load from that unpacked directory - 2nd argument (if exist) is the value for test_mode TARGET_DIR ./ DOWNLOAD_FLAG 0 test_mode 0 tx_offset_tuning_enable 0 $TARGET_DIR is found! network-manager stop/waiting rmmod: ERROR: Module sdr is not currently loaded rmmod: ERROR: Module ad9361_drv is not currently loaded + insmod .//ad9361_drv.ko ad9361_drv is loaded! .//system_top.bit.bin not found. Skip reloading FPGA. xlnx,zynq-7000 fjdo349ujtrueugjh
03-26
<think>嗯,用户这次聚焦在SSH访问的"Permission denied, please try again"报错上。从引用内容看,这个问题涉及多个层面的可能性,需要系统性地排查。用户应该是在管理Linux服务器时遇到了访问阻断,情绪可能比较焦虑——毕竟连不上服务器会直接影响工作。 先拆解引用中的有效信息:引用[2]直接关联SSH配置,提到PermitRootLogin和PubkeyAuthentication两个关键参数,还补充了HostKeyAlgorithms这个容易被忽略的算法兼容项;引用[3]则指出账号过期时间这种边缘case。有趣的是引用[1]和[4]虽然都提到Permission denied,但实际是公钥认证和Git权限问题,与当前问题相关性较弱。 用户明确要求解决交互式登录场景的报错(注意报错信息中带"please try again"),这和公钥认证失败报错文本不同。这说明更可能是密码认证或基础配置问题。需要重点检查:1)sshd_config里的密码认证开关 2)PAM模块限制 3)用户账号状态 4)selinux/firewall干扰。 考虑到用户可能是运维人员,在回复里加入具体命令示例会更实用。比如用chage命令检查账号过期时间,用semanage调整selinux策略这些具体操作。不过要注意提醒sudo权限需求,避免用户直接复制命令引发权限错误。 测试环节特别重要,用户可能没有意识到修改配置后需要重启sshd服务。这里要用$$语法强调重启命令的格式,因为CentOS7和Ubuntu22.04的命令不同(systemctl restart sshd vs service ssh restart)。对了,还要提醒测试时保留现有会话,防止配置错误导致完全断开连接。 最后想到个隐藏风险点:如果用户通过跳板机连接,实际报错来源可能是中转服务器。这个在回复里用括号补充说明比较合适,避免用户走弯路。 </think>针对SSH访问失败报错"Permission denied, please try again."的问题,结合引用内容及系统排查逻辑,解决方案如下: ### 一、核心配置检查(优先处理) 1. **启用密码登录** 修改`/etc/ssh/sshd_config`: ```bash sudo vim /etc/ssh/sshd_config ``` 确保以下参数为: ```nginx PasswordAuthentication yes # 允许密码登录 PermitRootLogin yes # 允许root登录(按需开启) PubkeyAuthentication yes # 开启公钥认证[^2] ``` **重启服务**生效: ```bash sudo systemctl restart sshd ``` 2. **密钥算法兼容性**(针对OpenSSH升级问题) 在相同文件末尾添加: ```nginx HostKeyAlgorithms +ssh-rsa # 兼容旧算法[^2] ``` --- ### 二、账户状态排查 1. **检查账户过期时间** ```bash sudo chage -l [用户名] # 查看账户有效期 ``` 若账户过期: ```bash sudo chage -E "2024-12-31" [用户名] # 延长有效期至指定日期[^3] ``` 2. **密码策略验证** ```bash sudo passwd [用户名] # 重置密码(触发密码状态更新) ``` --- ### 三、权限与SELinux 1. **关键目录权限** ```bash sudo chmod 700 ~/.ssh # 用户密钥目录 sudo chmod 600 ~/.ssh/authorized_keys # 公钥文件 ``` 2. **关闭SELinux临时测试** ```bash sudo setenforce 0 # 临时禁用 ``` > 若登录成功,需永久关闭需修改`/etc/selinux/config`中的`SELINUX=disabled` --- ### 四、连接测试与诊断 - **带调试信息连接**: ```bash ssh -vvv user@host # 显示详细错误流 ``` - **检查服务状态**: ```bash sudo systemctl status sshd # 确认服务运行 sudo journalctl -u sshd -n 50 # 查看最近50条日志 ``` ### 五、其他可能原因 - **防火墙拦截**: ```bash sudo ufw allow ssh # Ubuntu sudo firewall-cmd --add-service=ssh --permanent # CentOS ``` - **PAM模块限制**:检查`/etc/pam.d/sshd`是否有限制规则 - **用户Shell配置**:确保`/etc/passwd`中用户shell有效(如`/bin/bash`) > **关键提示**:修改配置后必须重启SSH服务方能生效: > $$ \text{执行命令: } \texttt{sudo systemctl restart sshd} $$
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值