Submission #00079


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<bits/stdc++.h>
using namespace std;
main(){
int n,m;
int mf[500]={0};
int ff[500][500]={0};
int a,b;
int l=0,fl=0,ag=0;
cin>>n>>m;
for(int i=0;i<m;i++){
cin>>a>>b;
if(a==1){
mf[l]=b;
l++;
}
if(b==1){
mf[l]=a;
l++;
}
if(a!=1 && b!=1){
while(fl==0 && ag==0){
for(int j=0;j<n;j++){
if(ff[a][j]==0 && fl==0){
ff[a][j]=b;
fl++;
}
if(ff[b][j]==0 && ag==0){
ff[b][j]=a;
ag++;
}
}
}
fl=0;
ag=0;
}
}
int cnt=0;
for(int i=0;i<n;i++){
if(mf[i]==0)break;
cnt++;
for(int j=2;j<=n;j++){
for(int k=0;k<n;k++){
if(ff[j][k]==mf[i]){
ff[j][k]=0;
}
}
}
}
int cou=0;
for(int i=2;i<=n;i++){
for(int j=0;j<n;j++){
if(ff[i][j]!=0 && ff[i][j]!=1){
for(int k=0;k<n;k++){
if(ff[i][j]==mf[k]){
cou++;
k+=n;
}
else if(i==mf[k]){
cou++;
k+=n;
}
}
}
}
}
if(cnt==0){
cout<<cnt<<endl;
}
else{
cout<<cnt+cou<<endl;
}
}

ステータス

項目 データ
問題 0001 - パーティ
ユーザー名 ei1541
投稿日時 2015-11-12 17:57:39
言語 C++11
状態 Wrong Answer
得点 20
ソースコード長 1108 Byte
最大実行時間 29 ms
最大メモリ使用量 1592 KB

セット

セット 得点 Cases
1 in1 20 / 20 in1.txt
2 in2 0 / 20 in2.txt
3 in3 0 / 20 in3.txt
4 in4 0 / 20 in4.txt
5 in5 0 / 20 in5.txt

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 12 ms 1368 KB
1
in2.txt WA 13 ms 1268 KB
2
in3.txt WA 15 ms 1288 KB
3
in4.txt WA 11 ms 1444 KB
4
in5.txt WA 29 ms 1592 KB
5