9 条题解

  • 48
    @ 2023-8-12 11:21:38

    image

    锯齿矩阵求解

    #include <bits/stdc++.h>
    using namespace std;
    vector<int> v[10005];
    int n,m;
    int x,y;
    int main(){
        cin >> n >> m;
        for (int i = 1;i <= m;i ++){
            cin >> x >> y;
            v[x].push_back(y);
        }
        for (int i = 1;i <= n;i ++){
            for (int j = 0;j < v[i].size();j ++){
                cout << v[i][j] << " ";
            }
            cout << endl;
        }
        return 0;
    }
    

    AC代码,点个赞再走呗~

  • 14
    @ 2024-4-6 9:06:37

    过辣!

    ↓↓↓这还不够详细?!↓↓↓

    #include <iostream>
    #include <algorithm>
    #include <cmath>
    #include <vector>
    using namespace std;
    typedef long unsigned int k;//为啥用这个,因为不想听编译提示狗叫
    int n , m , x , y;
    int main()
    {
        cin >> n >> m;
        vector<int> v[n+5];
        for (int i = 1; i <= m ; i++)
        {
            cin >> x >> y;
            v[x].push_back(y);
        }
        for (int i = 1 ; i <= n ; i++)
        {
            for (k j = 0 ; j < v[i].size() ; j++)
            {
                cout << v[i][j] << " ";
            }
            cout << endl;
        }
        return 0;
    }
    

    一份AC代码只需要一个赞了啊!

  • 14
    @ 2023-7-23 19:35:52
    #include <bits/stdc++.h>
    
    using namespace std;
    
    int x, y;
    vector<int> a[100000];
    
    int main() {
        int n, m;
        cin >> n >> m;
        for (int i = 0; i < m; i++) {
            cin >> x >> y;
            a[x].push_back(y);
        } for (int i = 1; i <= n; i++) {
            for (int j = 0; j < a[i].size(); j++)
                cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    
    
    • 9
      @ 2023-7-24 17:04:23

      精品题解

      FROM:丁丁


      题目大意

      存在一个每行不等长的矩阵,矩阵共有n行,存在m个操作,每个操作包括x和y,表示在第x行末尾插入一个元素y。


      解析

      建立一个vector数组v[10005],当前操作为{x, y},就将v[x].push_back(y),最后输出即可。


      关键代码
      • 定义部分:
      int x, y; 
      vector<int> a[100000]; ```
      

      • 主程序:
      for (int i = 0; i < m; i++) {
      cin >> x >> y;
      a[x].push_back(y);
      } for (int i = 1; i <= n; i++) {
      for (int j = 0; j < a[i].size(); j++)
      cout << a[i][j] << " ";
      cout << endl;
      }
      

      想对你说
      • 好好自己做 不要什么都抄 会一无所获的~
      • 加油!!
      • 6
        @ 2023-7-24 16:27:28

        精品题解

        FROM:丁丁


        题目大意

        存在一个每行不等长的矩阵,矩阵共有n行,存在m个操作,每个操作包括x和y,表示在第x行末尾插入一个元素y。

        建立一个vector数组v[10005],当前操作为{x, y},就将v[x].push_back(y),最后输出即可。

        关键代码

        定义部分:

        int x, y;
        vector<int> a[100000];
        

        主程序:

        for (int i = 0; i < m; i++) {
        cin >> x >> y;
        a[x].push_back(y);
        } for (int i = 1; i <= n; i++) {
        for (int j = 0; j < a[i].size(); j++)
        cout << a[i][j] << " ";
        cout << endl;
        }
        

        想对你说
        • 好好自己做 不要什么都抄 会一无所获的~
        • 加油!!
        • 3
          @ 2024-6-1 10:57:25
          #include <bits/stdc++.h>
          #define ll long long
          using namespace std;
          void start();
          const int N=2;
          vector<int> a[10005];
          int main(){
              start();
              int n,m,x,y;
              cin>>n>>m;
              while(m--){
                  cin>>x>>y;
                  a[x].push_back(y);
              }
              for(int i=1;i<=n;i++){
                  for(int j:a[i])
                      cout<<j<<' ';
                  cout<<'\n';
              }
              return 0;
          }
          void start(){
              // freopen(".in","r",stdin); 
              // freopen(".out","w",stdout);
              ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
          }
          
          • 3
            @ 2023-7-6 16:19:47
            题目大意
                     存在一个每行不等长的矩阵,矩阵共有n行,存在m个操作,每个操作包括x和y,表示在第x行末尾插入一个元素y。

            完整思路
                    建立一个vector数组v[10005],当前操作为{x, y},就将v[x].push_back(y),最后输出即可。

            题解
            
            vector<int> v[10005];
            // 保存
            for (int i = 1; i <= m; i++)
            {
                int x, y;
                cin >> x >> y;
                v[x].push_back(y);
            }
            // 输出
            for (int i = 1; i <= n; i++)
            {
                for (int j = 0; j < v[i].size(); j++)
                {
                    cout << v[i][j] << " ";
                }
                cout << endl;
            }
            
            
            • @ 2023-7-23 19:26:14

              真题解

            • @ 2023-8-23 20:16:12

              @ [[[[[[[[[[[](https://)](https://)](https://)](https://)](https://)](https://)](https://)](https://)](https://)](https://)](https://)

          • 2
            @ 2024-3-1 20:22:51
            #include <iostream>
            using namespace std;
            vector<int> v[10005];
            int n,m;
            int x,y;
            int main(){
                cin >> n >> m;
                for (int i = 1;i <= m;i ++){
                    cin >> x >> y;
                    v[x].push_back(y);
                }
                for (int i = 1;i <= n;i ++){
                    for (int j = 0;j < v[i].size();j ++){
                        cout << v[i][j] << " ";
                    }
                    cout << endl;
                }
                return 0;
            }
            

            已AC代码,点个赞呗!

            • -5
              @ 2024-3-17 15:39:24

              cpp``` #include <iostream> using namespace std; int main() {

              }

              
              
              • 1

              信息

              ID
              252
              时间
              1000ms
              内存
              256MiB
              难度
              1
              标签
              (无)
              递交数
              671
              已通过
              470
              上传者