90pts求助!悬赏关注!

P1042 [NOIP2003 普及组] 乒乓球

这题你用链表做???(惊,不是模拟吗
by awdereye @ 2023-10-07 21:29:04


头文件瞩目()
by Hatsunatsu @ 2023-10-07 21:31:12


恭喜你被卡bug了。 正解 ```cpp #include<bits/stdc++.h> #include<algorithm> #include<bitset> #include<cctype> #include<cerrno> #include<clocale> #include<cmath> #include<complex> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<deque> #include<exception> #include<fstream> #include<functional> #include<limits> #include<list> #include<map> #include<iomanip> #include<ios> #include<iosfwd> #include<iostream> #include<queue> #include<set> #include<sstream> #include<stack> #include<stdexcept> #include<streambuf> #include<string> #include<utility> #include<vector> #include<cwchar> #include<cwctype> #include<complex.h> #include<fenv.h> #include<inttypes.h> #include<stdbool.h> #include<stdint.h> #include<tgmath.h> using namespace std ; struct stu{ bool win ; stu *next ; } *head , *p , *q , *h ; int main () { int l , r ; l = 0 ; r = 0 ; head = new stu ; p = head ; q = head ; h = head ; char a ; while ( ( a = getchar() ) != EOF && a != 'E' ) { if ( a == '\n' || a == '\r' || a == ' ' ) { continue ; } p->next = nullptr ; if ( a == 'W' ) { p->win = true ; } if ( a == 'L' ) { p->win = false ; } q = p ; p = new stu ; q->next = p ; } if ( p == head ) { cout << "0:0\n\n0:0" ; return 0 ; } while ( h->next != nullptr ) { if ( h->win ) { l++ ; if ( l >= 11 && l - r >= 2 ) { cout << l << ":" << r << endl ; l = 0 ; r = 0 ; } } else { r++ ; if ( r >= 11 && r - l >= 2 ) { cout << l << ":" << r << endl ; l = 0 ; r = 0 ; } } h = ( h->next ) ; } cout << l << ":" << r << endl ; l = 0 ; r = 0 ; cout << endl ; h = head ; while ( h->next != nullptr ) { if ( h->win ) { l++ ; if ( l >= 21 && l - r >= 2 ) { cout << l << ":" << r << endl ; l = 0 ; r = 0 ; } } else { r++ ; if ( r >= 21 && r - l >= 2 ) { cout << l << ":" << r << endl ; l = 0 ; r = 0 ; } } h = ( h->next ) ; } if ( ! ( l || r ) ) { return 0 ; } cout << l << ":" << r << endl ; return 0 ; } ``` 把你的 ```cpp if ( l || r ) { cout << l << ":" << r << endl ; } ``` 改成 ```cpp cout << l << ":" << r << endl ; ``` 就过了(
by awdereye @ 2023-10-07 22:06:59


你大号已经关注我了拿小号也行(bushiu
by awdereye @ 2023-10-07 22:40:57


666
by I__AK__IOI___ @ 2023-10-08 20:10:22


其实我已经过了,但是我觉得链表好好玩
by I__AK__IOI___ @ 2023-10-08 20:11:19


|