#6457: 為何執行區段錯誤??


gcobs104628 (毛)

學校 : 臺北市立成功高級中學
編號 : 23396
來源 : [61.60.254.25]
最後登入時間 :
2017-04-15 22:42:23
d914. 2. 圍棋資料庫比對 -- 99學年度全國資訊學科能力競賽 | From: [114.24.67.79] | 發表日期 : 2012-03-11 02:18

#include<iostream>
using namespace std;
main()
{
      int a;
      while(cin>>a)
      {
                   int z[20][20]={0},d[20][20]={0},total=0,h[20][20]={0};
                   for(int i=1;i<=a;i++)
                   {
                           int b,c;
                           cin>>b>>c>>d[b][c];
                           d[b][c]++;
                           z[b][c]=1;
                   }
                   int e;
                   cin>>e;
                   for(int i=1;i<=e;i++)
                   {
                           int f,g;
                           cin>>f>>g>>h[f][g];
                           z[f][g]=1;
                           h[f][g]++;
                   }
                   for(int i=1;i<=19;i++)
                   {
                           for(int y=1;y<=19;y++)
                           {
                                   if(z[y][i]==1)
                                   {
                                                 if(d[y][i]!=h[y][i])
                                                 {
                                                                     if(d[y][i]!=0&&h[y][i]!=0)total+=2;
                                                                     else total++;
                                                 }
                                   }
                           }
                   }
                   cout<<total<<endl;
       }
return 0;
}
                                                
                                                 
                             
ZeroJudge Forum