제출 #469815

#제출 시각아이디문제언어결과실행 시간메모리
469815AdamGSConnecting Supertrees (IOI20_supertrees)C++14
21 / 100
259 ms28012 KiB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
int construct(vector<vector<int>>p) {
	int n=p[0].size();
	vector<pair<vector<int>,int>>V;
	rep(i, n) {
		vector<int>a;
		rep(j, n) if(p[i][j]) a.pb(1); else a.pb(0);
		V.pb({a, i});
	}
	sort(all(V));
	vector<vector<int>>spojne;
	vector<int>akt1=V[0].st, akt2;
	akt2.pb(V[0].nd);
	for(int i=1; i<V.size(); ++i) {
		if(V[i].st!=akt1) {
			vector<int>jakie;
			rep(j, n) if(akt1[j]) jakie.pb(j);
			if(jakie!=akt2) return 0;
			spojne.pb(akt2);
			akt1=V[i].st;
			akt2.clear();
		}
		akt2.pb(V[i].nd);
	}
	vector<int>jakie;
	rep(j, n) if(akt1[j]) jakie.pb(j);
	if(jakie!=akt2) return 0;
	spojne.pb(akt2);
	vector<vector<int>>ans;
	rep(i, n) {
		vector<int>a;
		rep(j, n) a.pb(0);
		ans.pb(a);
	}
	for(auto i : spojne) {
		rep(j, i.size()-1) {
			ans[i[j]][i[j+1]]=ans[i[j+1]][i[j]]=1;
		}
	}
	build(ans);
	return 1;
}

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:23:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::vector<int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i=1; i<V.size(); ++i) {
      |               ~^~~~~~~~~
supertrees.cpp:6:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
supertrees.cpp:45:3: note: in expansion of macro 'rep'
   45 |   rep(j, i.size()-1) {
      |   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...