給一個含n個點 m條邊的連通圖 把k個人分成兩組 輪流拿掉一條邊 當取走一條邊后圖不再連通 這個隊就輸了
水題啦 邊為n-1時 下一個拿掉邊的那個組就輸啦
AC代碼:
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 typedef unsigned long long ull; 5 int main(){ 6 ll t, k, n, m, u, v; 7 char s[100005]; 8 cin>>t; 9 while (t--){ 10 memset(s, 0, sizeof(s)); 11 cin>>k; 12 cin>>s; 13 cin>>n>>m; 14 for (int i = 0; i < m; i++) cin>>u>>v; 15 if (m - n + 1 > 0){ 16 if (s[(m - n + 1) % k] == '1') cout<<2<<endl; 17 else if (s[(m - n + 1) % k] == '2') cout<<1<<endl; 18 } 19 else{ 20 if (s[0] == '1') cout<<2<<endl; 21 else if (s[0] == '2') cout<<1<<endl; 22 } 23 } 24 return 0; 25 }
?