UVA - 489????????Hangman Judge

Hangman Judge

?UVA - 489?

題目傳送門

PS.此題Udebug有毒,即使100組樣例全過,但還是WA,心塞。

這是我自己的代碼,悲催的WA了

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
int main() 
{#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);#endiffreopen("out.txt", "w", stdout);ios::sync_with_stdio(0),cin.tie(0);int T;while(cin>>T&&T!=-1){string s1,s2;cin>>s1>>s2;int len1=s1.size();int len2=s2.size();set<char> ss1; ss1.clear();set<char> ss2; ss2.clear();map<char,bool> m;m.clear();map<char,bool> m1;m1.clear();rep(i,0,len1-1) {ss1.insert(s1[i]);ss2.insert(s2[i]);}int size1=ss1.size();int num=0,nape,k=0;bool ju=false;rep(i,0,len2-1) {ss1.insert(s2[i]);nape=ss1.size();if(nape==size1) {if(m[s2[i]]==false) {m[s2[i]]=true;k++;if(k==size1&&num<6){ju=true;break;}}}else{ss1.erase(s2[i]);if(m1[s2[i]]==false)num++;m1[s2[i]]=true;}}cout<<"Round "<<T<<endl;if(ju) cout<<"You win."<<endl;if(k!=size1&&num<=6) cout<<"You chickened out."<<endl;if(num>6) cout<<"You lose."<<endl;}return 0;
}

下面是我找到的一個AC代碼:

#include<bits/stdc++.h>
using namespace std;
int leftt,chance;//left表示還剩多少沒有猜對,chance表示還有幾次可以猜錯
char s[200],s2[200];
int win,lose;
void guess(char ch)
{int bad=1;for(int i=0; i<strlen(s); i++){if(ch==s[i]){leftt--;s[i]=' ';bad=0;}}if(bad)chance--;if(!leftt)win=1;if(!chance)lose=1;
}
int main()
{int rnd;while(~scanf("%d",&rnd),rnd!=-1){scanf("%s %s",s,s2);printf("Round %d\n",rnd);win=lose=0;leftt=strlen(s);chance=7;for(int i=0; i<strlen(s2); i++){guess(s2[i]);if(win||lose)break;}if(win)printf("You win.\n");else if(lose)printf("You lose.\n");elseprintf("You chickened out.\n");memset(s,'\0',sizeof(s));memset(s2,'\0',sizeof(s2));}return 0;
}

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/536319.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/536319.shtml
英文地址,請注明出處:http://en.pswp.cn/news/536319.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

UVA - 133????????The Dole Queue

The Dole Queue UVA - 133 題目傳送門 模擬一遍過程&#xff0c;注&#xff1a;可能會選中同一個人 AC代碼&#xff1a; #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstdlib> #include <c…

UVA - 213?Message Decoding

Message Decoding UVA - 213 題目傳送門 emmmm&#xff0c;此題按照紫書上的思路來即可&#xff0c;要么太復雜 AC代碼&#xff1a; #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstdlib> #in…

UVA - 512????????Spreadsheet Tracking

Spreadsheet Tracking UVA - 512 題目傳送門 紫書第二個思路十分巧妙&#xff0c;能用很少的代碼解出此題。 AC代碼&#xff1a; #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstdlib> #inclu…

UVA - 1589????????Xiangqi

Xiangqi UVA - 1589 題目傳送門 解決方法&#xff1a;判斷黑棋是否能有可以下的地方 AC代碼&#xff1a; #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #in…

UVA - 12412????????A Typical Homework (a.k.a Shi Xiong Bang Bang Mang)

A Typical Homework (a.k.a Shi Xiong Bang Bang Mang) UVA - 12412 題目傳送門 emmmm&#xff0c;不想表達什么&#xff0c;udbug上的數據全過&#xff0c;可就是WA。。。。 AC了的代碼&#xff08;大佬的代碼&#xff09; #include <bits/stdc.h> using namespace…

【思維】draw!

題目&#xff1a; You still have partial information about the score during the historic football match. You are given a set of pairs (ai,bi)(ai,bi), indicating that at some point during the match the score was "aiai: bibi". It is known that if t…

【數學】Birthday

題目&#xff1a; Cowboy Vlad has a birthday today! There are nn children who came to the celebration. In order to greet Vlad, the children decided to form a circle around him. Among the children who came, there are both tall and low, so if they stand in a…

【遞推】Ayoub and Lost Array

題目&#xff1a;Ayoub had an array aa of integers of size nn and this array had two interesting properties: All the integers in the array were between ll and rr (inclusive). The sum of all the elements was divisible by 33. Unfortunately, Ayoub has lost hi…

Super-palindrome【字符串+思維】

Super-palindrome 時間限制: 1 Sec 內存限制: 128 MB 提交: 595 解決: 231 [提交] [狀態] [命題人:admin] 題目描述 You are given a string that is consisted of lowercase English alphabet. You are supposed to change it into a super-palindrome string in minimum ste…

Hakase and Nano【博弈】

Hakase and Nano 時間限制: 1 Sec 內存限制: 128 MB 提交: 533 解決: 155 [提交] [狀態] [命題人:admin] 題目描述 Hakase and Nano are playing an ancient pebble game (pebble is a kind of rock). There are n packs of pebbles, and the i-th pack contains ai pebble…

【思維】過分的謎題

題目描述 2060年是云南中醫學院的百年校慶&#xff0c;于是學生會的同學們搞了一個連續猜謎活動&#xff1a;共有10個謎題&#xff0c;現在告訴所有人第一個謎題&#xff0c;每個謎題的答案就是下一個謎題的線索....成功破解最后一個謎題后&#xff0c;答案就是指向獎勵的線索…

【bfs】調酒壺里的酸奶

題目描述 最近小w學了一手調酒的技巧&#xff0c;這么帥的操作&#xff0c;說不定能靠這個俘獲女神的芳心&#xff0c;為了在女神面前露一手&#xff0c;他想在學校里建一個"pub"&#xff0c;但是顯然學校不可能讓他真的建一個"pub"&#xff0c;那么他退而…

【dfs】Election of Evil

題目描述 Dylan is a corrupt politician trying to steal an election. He has already used a mind-control technique to enslave some set U of government representatives. However, the representatives who will be choosing the winner of the election is a di?ere…

【思維】Iranian ChamPions Cup

題目描述 The Iranian ChamPions Cup (ICPC), the most prestigious football league in Iran, is reaching its end, and people are eagerly waiting for the finals, which happened to be between the two most popular Iranian teams, Persepolis and Esteghlal. The ICP…

【數學】Chaarshanbegaan at Cafebazaar

題目描述 Chaarshanbegaan is a gathering event at Cafebazaar similar to TGIF events at Google. Some entertainment programs like pantomime, foosball, Xbox/PS4, and several board games are part of the event. You are going to set up a dart game in Chaarshanbe…

【思維】Congestion Charging Zone

題目描述 Tehran municipality has set up a new charging method for the Congestion Charging Zone (CCZ) which controls the passage of vehicles in Tehran’s high-congestion areas in the congestion period (CP) from 6:30 to 19:00. There are plate detection came…

【二分】LED

題目描述 A Light-Emitting Diode (LED) is a semiconductor light source, which emits light when an electric current of voltage higher than a threshhold is applied to its leads. ACM R&D recently reported that they have succesfully developed a new LED, na…

【差分數組】Master of GCD

題目描述 Hakase has n numbers in a line. At fi rst, they are all equal to 1. Besides, Hakase is interested in primes. She will choose a continuous subsequence [l, r] and a prime parameter x each time and for every l≤i≤r, she will change ai into ai*x. To…

【模擬】Ground Defense

題目描述 You are a denizen of Linetopia, whose n major cities happen to be equally spaced along an east-west line. In fact, they are often numbered in order from 1 to n, where 1 is the westmost city and n is the eastmost city. Linetopia was a lovely plac…

【模擬】Bulbs

題目描述 Greg has an m n grid of Sweet Lightbulbs of Pure Coolness he would like to turn on. Initially, some of the bulbs are on and some are off. Greg can toggle some bulbs by shooting his laser at them. When he shoots his laser at a bulb, it toggles th…