/*************************************************************************
* *
* XVIII Olimpiada Informatyczna *
* *
* Zadanie: Impreza *
* Autor: Alan Kutniewski *
* Zlozonosc czasowa: O(n^2) *
* Opis: Rozwiazanie wzorcowe *
* *
*************************************************************************/
#include <iostream>
#define MAXN 3000
using namespace std;
bool kmatrix[MAXN][MAXN]; //macierz sąsiedztwa
bool erased[MAXN]; //czy usunięty?
int n, m, a, b; //jak w treści
int main(){
ios_base::sync_with_stdio(0);
cin >> n >> m; //wczytywanie danych
for(int i = 0; i < m; ++i){
cin >> a >> b;
kmatrix[a-1][b-1] = kmatrix[b-1][a-1] = 1;
} //usuwanie nieznających się par
for(int i = 0; i < n; ++i){
for(int j = i + 1; j < n && !erased[i]; ++j){ //dopóki i nieusunięty
if(!kmatrix[i][j] && !erased[j]){ //jeśli i nie zna j i j nieusunięty
erased[i] = 1; //to usuwamy i oraz j
erased[j] = 1;
}
}
}
int left = (n/3); //ile zostało do wypisania
for(int i = 0; left && i < n; ++i){
if(!erased[i]){ //jeśli nie usunęliśmy i
--left; //to wypisujemy i zmniejszamy ilość
cout << i+1 << " ";
}
}
cout << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
10972 KB |
Output is correct |
2 |
Correct |
0 ms |
10972 KB |
Output is correct |
3 |
Correct |
0 ms |
10972 KB |
Output is correct |
4 |
Correct |
0 ms |
10972 KB |
Output is correct |
5 |
Correct |
0 ms |
10972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
10972 KB |
Output is correct |
2 |
Correct |
16 ms |
10972 KB |
Output is correct |
3 |
Correct |
16 ms |
10972 KB |
Output is correct |
4 |
Correct |
19 ms |
10972 KB |
Output is correct |
5 |
Correct |
19 ms |
10972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
10972 KB |
Output is correct |
2 |
Correct |
86 ms |
10972 KB |
Output is correct |
3 |
Correct |
86 ms |
10972 KB |
Output is correct |
4 |
Correct |
96 ms |
10972 KB |
Output is correct |
5 |
Correct |
96 ms |
10972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
10972 KB |
Output is correct |
2 |
Correct |
296 ms |
10972 KB |
Output is correct |
3 |
Correct |
263 ms |
10972 KB |
Output is correct |
4 |
Correct |
263 ms |
10972 KB |
Output is correct |
5 |
Correct |
279 ms |
10972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
10972 KB |
Output is correct |
2 |
Correct |
423 ms |
10972 KB |
Output is correct |
3 |
Correct |
423 ms |
10972 KB |
Output is correct |
4 |
Correct |
449 ms |
10972 KB |
Output is correct |
5 |
Correct |
423 ms |
10972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
266 ms |
10972 KB |
Output is correct |
2 |
Correct |
533 ms |
10972 KB |
Output is correct |
3 |
Correct |
509 ms |
10972 KB |
Output is correct |
4 |
Correct |
536 ms |
10972 KB |
Output is correct |
5 |
Correct |
513 ms |
10972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
416 ms |
10972 KB |
Output is correct |
2 |
Correct |
669 ms |
10972 KB |
Output is correct |
3 |
Correct |
669 ms |
10972 KB |
Output is correct |
4 |
Correct |
656 ms |
10972 KB |
Output is correct |
5 |
Correct |
743 ms |
10972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
499 ms |
10972 KB |
Output is correct |
2 |
Correct |
816 ms |
10972 KB |
Output is correct |
3 |
Correct |
616 ms |
10972 KB |
Output is correct |
4 |
Correct |
763 ms |
10972 KB |
Output is correct |
5 |
Correct |
643 ms |
10972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
723 ms |
10972 KB |
Output is correct |
2 |
Correct |
889 ms |
10972 KB |
Output is correct |
3 |
Correct |
646 ms |
10972 KB |
Output is correct |
4 |
Correct |
1002 ms |
10972 KB |
Output is correct |
5 |
Correct |
716 ms |
10972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
813 ms |
10972 KB |
Output is correct |
2 |
Correct |
989 ms |
10972 KB |
Output is correct |
3 |
Correct |
1113 ms |
10972 KB |
Output is correct |
4 |
Correct |
1173 ms |
10972 KB |
Output is correct |
5 |
Correct |
1036 ms |
10972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1089 ms |
10972 KB |
Output is correct |
2 |
Correct |
1196 ms |
10972 KB |
Output is correct |
3 |
Correct |
1196 ms |
10972 KB |
Output is correct |
4 |
Correct |
1203 ms |
10972 KB |
Output is correct |
5 |
Correct |
1246 ms |
10972 KB |
Output is correct |