제출 #212710

#제출 시각아이디문제언어결과실행 시간메모리
212710BThero조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2)C++17
1 / 100
22 ms512 KiB
#define DBG 1
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) if (DBG) cerr << #x << " = " << x << endl;

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pii;

//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int adj[55][55];
int n, m, ans;

void push() {
    bool did = 0;
    
    do {
        did = 0;
        
        for (int x = 1; x <= n; ++x) {
            for (int y = 1; y <= n; ++y) {
                if (x != y && adj[x][y]) {
                    for (int z = 1; z <= n; ++z) {
                        if (x != z && y != z && adj[y][z] && adj[z][y] && adj[x][z] == 0) {
                            adj[x][z] = 1;
                            ++ans;
                            did = 1;
                        }
                    }
                }
            }
        }
    }
    while (did);
}

void solve() {
	scanf("%d %d", &n, &m);
    
    for (int i = 1; i <= m; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        
        if (adj[u][v] == 0) {
            adj[u][v] = 1;
            ++ans;
            push();
        }
        
        printf("%d\n", ans);
    }
}

int main() {
	int tt = 1;
	
	while (tt--) {
		solve();
	}

	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

joitter2.cpp: In function 'void solve()':
joitter2.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
joitter2.cpp:54:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &u, &v);
         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...