全 WA 但不知道错在哪
查看原帖
全 WA 但不知道错在哪
1086443
Innate_Joker楼主2025/1/1 17:59
#include <vector>
#include <iostream>
#define MAXN 1005
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    bool matrices[MAXN][MAXN] {};
    vector<int> meter[MAXN];
    for (int i = 1; i <= m; i++ ) {
        int x, y;
        cin >> x >> y;
        matrices[x][y] = true;
        matrices[y][x] = true;
        meter[x].push_back(y);
        meter[y].push_back(x);
    }
    for (int i = 1; i <= n; i++ ) {
        for (int j = 1; j <= n; j++ ) {
            cout << matrices[i][j] << ' ';
        }
        cout << endl;
    }
    for (int i = 1; i <= n; i++ ) {
        int meter_len = meter[i].size();
        cout << meter_len << ' ';
        for (int j = 0; j < meter_len; j++ ) {
            cout << meter[i][j] << ' ';
        }
        cout << endl;
    }
    system("pause");
    return 0;
}
2025/1/1 17:59
加载中...