#14772: WA 怎麼過不了呢.....


samisthegod (aaa878787)


#include<iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int n,m;
while(cin>>n>>m)
{
int o=0,e=0,a,b,s[n]={0};
for(int i=1;i<=m;i++)
{
cin>>a>>b;
s[a]++; s[b]++;
}
for(int i=1;i<=n;i++)
{
if(s[i]%2==1) o++;
else if(s[i]%2==0) e++;
}
if(o==2 || o==0) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}

 

#0: 13% WA (line:1)

您的答案為: NO
正確答案為: YES
#14777: Re:WA 怎麼過不了呢.....


songshan (松山高中資訊研究社)


#include
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int n,m;
while(cin>>n>>m)
{
int o=0,e=0,a,b,s[n]={0};
for(int i=1;i<=m;i++)
{
cin>>a>>b;
s[a]++; s[b]++;
}
for(int i=1;i<=n;i++)
{
if(s[i]%2==1) o++;
else if(s[i]%2==0) e++;
}
if(o==2 || o==0) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}

 

#0: 13% WA (line:1)

您的答案為: NO
正確答案為: YES


s[n]的寫法不是正確寫法,

編譯時會出問題,

導致程式即使編譯成功,

也不一定按照你的想法執行。

寫個s[10000]吧。