ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1151. Radiobeacons

Show all messages Hide all messages

I'm sure I got WA because of reading string.
Please help me, thanks.
Here is my code to read string :
...
fscanf(stdin,"%d\n",&m) ;
   for(int i=0;i<m;i++) {
       char s[1000] ;
         int j = 0 , k = 0 ;
         fscanf(stdin,"%s",&s) ;
         while ( s[j] != ',' ) a[i].x = a[i].x * 10 + s[j++] - 48 ;
         j++ ;
         while ( s[j] != ':' ) a[i].y = a[i].y * 10 + s[j++] - 48 ;
         j++ ;
         while (j < strlen(s) ) {
               while ( s[j] != '-' ) b[i][k] = b[i][k] * 10 + s[j++] - 48 ;
               j++ ;
               while ( j < strlen(s) && s[j] != ',' ) c[i][k] = c[i][k] * 10 + s[j++] - 48 ;
               k++ ;
               if ( s[j] == '\n' ) { j++ ; break ; }
               j++ ;
         }
         deg[i] = k ;
     }
scanf("%d\n",&n);
    int i;
    int id,x,y,r;
    for (i = 0 ; i<n ; i++){
        scanf("%d,%d:",&x,&y);
        while (true){
            scanf("%d-%d",&id,&r);

            a[id][cnt[id]].x = x;
            a[id][cnt[id]].y = y;
            a[id][cnt[id]].r = r;
            cnt[id]++;
            char ch;

            ch = getc(stdin);
            if (ch!=',') break;
        }

    }
or:
for (int i=0; i<m; i++){
     char buf;
     cin >> tmp.x >> buf >> tmp.y;
     while ((buf=cin.get())!='\n' && buf!=EOF){
      int id;
      cin >> id >> buf >>tmp.r;
      a[id].push_back(tmp);
     }
}