3 条题解

  • 1
    #include<bits/stdc++.h>
    typedef long long ll; //长整型简写
    typedef char ch; //字符简写
    typedef double db; //双精度浮点数简写
    const double pi=acos(-1.0); //π定义
    const double e=exp(1.0); //e定义
    #define nullptr NULL //适配c++98
    using namespace std;
    signed main() //有符号主函数
    {
        ios::sync_with_stdio(false); //关闭c/c++输入输出关联
        cin.tie(nullptr); //关闭自动刷新输出缓冲区功能
         int n;
        cin>>n;
        vector<vector<int>> children(n + 1); 
        for (int i = 1; i <= n; ++i) {
            int ci;
            cin >> ci;
            for (int j = 0; j < ci; ++j) {
                int child;
                cin >> child;
                children[i].push_back(child);
            }
        }
        int maxGrandchildren = -1;
        int resultNode = -1;
        for (int node = 1; node <= n; ++node) {
            int count = 0;
            for (int child : children[node]) 
                count += children[child].size();
            if (count > maxGrandchildren || (count == maxGrandchildren && node < resultNode)) {
                maxGrandchildren = count;
                resultNode = node;
            }
        }
        cout << resultNode <<' '<< maxGrandchildren;
        return 0;
    }
    //沈齐宸.sqc制作模板 Copyright (C)  2025-2025
    
  • 1
    #include <iostream>
    #include <vector>
    using namespace std;
    
    int main() {
        int n;
        cin >> n;
        vector<vector<int>> children(n + 1); // 节点编号从1到n
    
        for (int i = 1; i <= n; ++i) {
            int ci;
            cin >> ci;
            for (int j = 0; j < ci; ++j) {
                int child;
                cin >> child;
                children[i].push_back(child);
            }
        }
    
        int maxGrandchildren = -1;
        int resultNode = -1;
    
        for (int node = 1; node <= n; ++node) {
            int count = 0;
            // 遍历当前节点的所有子节点
            for (int child : children[node]) {
                // 遍历子节点的所有子节点(即当前节点的孙子节点)
                count += children[child].size();
            }
            // 更新最多孙子节点的节点
            if (count > maxGrandchildren || (count == maxGrandchildren && node < resultNode)) {
                maxGrandchildren = count;
                resultNode = node;
            }
        }
    
        cout << resultNode << " " << maxGrandchildren << endl;
    
        return 0;
    }
    ```**绝对能过**
    
  • -2

    <?php
    // 开启 session
    session_start();

    // 如果已经登录,重定向到主页
    if (isset(\(_SESSION['admin']) && \)_SESSION['admin'] === true) {
    header("Location: index.php");
    exit();
    }

    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    include("conn.php");

    // 获取表单数据
    \(name = \)_POST['username'];
    \(password = \)_POST['password'];
    \(mdpassword = md5(\)password); // 将密码进行 md5 加密

    // 查询数据库
    \(db = new Database();
    \)result = \(db->findone("SELECT * FROM admin WHERE name='\)name'");

    // 验证用户名和密码
    if (\(result) {
    if (\)result["password"] === \(mdpassword) {
    echo "登入成功";
    \)_SESSION['admin'] = true;
    \(_SESSION['username'] = \)name;

    // 根据 session 中的 repage 值决定重定向地址
    if (isset(\(_SESSION['repage'])) {
    header("Location: " . \)_SESSION['repage']);
    } else {
    header("Location: index.php");
    }
    exit();
    } else {
    exit("密码错误");
    }
    } else {
    exit("用户名错误");
    }

    }
    ?>

    <html>
    <head>
    <title>欢迎登入</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </head>
    <body>
    <div class="container">
    <h1>欢迎登入</h1>
    <form action="login.php" method="post">
    <div class="form-group">
    <label for="username">用户名:</label>
    <input type="text" class="form-control" id="username" name="username" placeholder="请输入账号" required>
    </div>
    <div class="form-group">
    <label for="password">密码:</label>
    <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码" required>
    </div>
    <button type="submit" class="btn btn-default">登入</button>
    <button type="button" class="btn btn-default" onclick="window.location.href='register.php'">注册</button>
    </form>
    </div>
    </body>
    </html>

  • 1

信息

ID
1012
难度
6
分类
(无)
标签
递交数
40
已通过
11
通过率
28%
被复制
5
上传者