UVa 489 - Hangman Judge
//Accepted
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<char, bool>mpci;
typedef map<int, bool>mpbi;
const int mod = 1000007;
const int high = 100;
int main()
{
fast;
//freopen("out.txt" , "w" , stdout);
int t , i , slen, glen , stroke=0 , cnt=0, j;
string sol , guess;
mpbi mp;
while(cin >> t and t > -1)
{
mp.clear();
cin >> sol >> guess;
stroke = cnt = 0;
slen = sol.length();
glen = guess.length();
bool f=false;
for(i=0; i<glen; i++)
{
f=false;
if(stroke >= 7) break;
for(j=0; j<slen; j++)
{
if(guess[i] == sol[j] and !mp[j])
{
cnt++;
f=true;
mp[j] = true;
}
}
if(!f)
{
stroke++;
}
}
cout << "Round " << t << "\n";
if(cnt == slen) cout << "You win.\n";
else if(stroke >= 7) cout << "You lose.\n";
else cout << "You chickened out.\n";
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<char, bool>mpci;
typedef map<int, bool>mpbi;
const int mod = 1000007;
const int high = 100;
int main()
{
fast;
//freopen("out.txt" , "w" , stdout);
int t , i , slen, glen , stroke=0 , cnt=0, j;
string sol , guess;
mpbi mp;
while(cin >> t and t > -1)
{
mp.clear();
cin >> sol >> guess;
stroke = cnt = 0;
slen = sol.length();
glen = guess.length();
bool f=false;
for(i=0; i<glen; i++)
{
f=false;
if(stroke >= 7) break;
for(j=0; j<slen; j++)
{
if(guess[i] == sol[j] and !mp[j])
{
cnt++;
f=true;
mp[j] = true;
}
}
if(!f)
{
stroke++;
}
}
cout << "Round " << t << "\n";
if(cnt == slen) cout << "You win.\n";
else if(stroke >= 7) cout << "You lose.\n";
else cout << "You chickened out.\n";
}
return 0;
}
Comments
Post a Comment