/ SB域 /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 2ms 312.0 KiB
#2 Accepted 3ms 320.0 KiB
#3 Accepted 1ms 220.0 KiB
#4 Accepted 2ms 212.0 KiB
#5 Accepted 1ms 208.0 KiB
#6 Accepted 4ms 216.0 KiB
#7 Accepted 2ms 220.0 KiB
#8 Accepted 2ms 212.0 KiB
#9 Accepted 2ms 216.0 KiB
#10 Accepted 3ms 216.0 KiB

代码

#include<iostream>

using namespace std;

int n;
bool a[99][99];

void init() {
    int m, x, y;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        x--, y--;
        a[x][y] = true;
    }
}

void floyed() {
    for (int k = 0; k < n; k++)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                a[i][j] = a[i][j] || (a[i][k] && a[k][j]);
}

void print() {
    int mid = (n + 1) / 2, c = 0, c1, c2;
    for (int v = 0; v < n; v++) {
        c1 = 0, c2 = 0;
        for (int i = 0; i < n; i++) {
            if (a[v][i]) c1++;
            if (a[i][v]) c2++;
        }
        if (c1 >= mid || c2 >= mid) c++;
    }
    cout << c << endl;
}

int main() {
    init();
    floyed();
    print();
    return 0;
}

信息

递交者
类型
递交
题目
珍珠
题目数据
下载
语言
C++
递交时间
2019-06-13 18:12:04
评测时间
2019-06-13 18:12:04
评测机
分数
100
总耗时
27ms
峰值内存
320.0 KiB