-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding uva and 2 codeforces problems
- Loading branch information
aajjbb
committed
Jun 1, 2015
1 parent
c9e5316
commit 19e3a4b
Showing
7 changed files
with
139 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <bits/stdc++.h> | ||
|
||
template<typename T> T gcd(T a, T b) { | ||
if(!b) return a; | ||
return gcd(b, a % b); | ||
} | ||
template<typename T> T lcm(T a, T b) { | ||
return a * b / gcd(a, b); | ||
} | ||
|
||
template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; } | ||
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; } | ||
int in() { int x; scanf("%d", &x); return x; } | ||
|
||
using namespace std; | ||
|
||
typedef long long Int; | ||
typedef unsigned uint; | ||
|
||
string S; | ||
|
||
bool isletter(char c) { | ||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); | ||
} | ||
|
||
int main(void) { | ||
set<string> dict; | ||
|
||
while (getline(cin, S)) { | ||
int N = (int) S.size(); | ||
string buff = ""; | ||
|
||
for (int i = 0; i < N; i++) { | ||
if (isletter(S[i])) { | ||
buff += S[i]; | ||
} else { | ||
if (!buff.empty()) { | ||
transform(buff.begin(), buff.end(), buff.begin(), ::tolower); | ||
dict.insert(buff); | ||
} | ||
buff = ""; | ||
} | ||
} | ||
if (!buff.empty()) { | ||
transform(buff.begin(), buff.end(), buff.begin(), ::tolower); | ||
dict.insert(buff); | ||
} | ||
} | ||
|
||
for (string curr: dict) { | ||
cout << curr << "\n"; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <bits/stdc++.h> | ||
|
||
template<typename T> T gcd(T a, T b) { | ||
if(!b) return a; | ||
return gcd(b, a % b); | ||
} | ||
template<typename T> T lcm(T a, T b) { | ||
return a * b / gcd(a, b); | ||
} | ||
|
||
template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; } | ||
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; } | ||
int in() { int x; scanf("%d", &x); return x; } | ||
|
||
using namespace std; | ||
|
||
typedef long long Int; | ||
typedef unsigned uint; | ||
|
||
string S; | ||
int F[500]; | ||
|
||
bool st(pair<int, int> a, pair<int, int> b) { | ||
if (a.first != b.first) { | ||
return a.first < b.first; | ||
} else { | ||
return a.second > b.second; | ||
} | ||
} | ||
|
||
int main(void) { | ||
bool done = false; | ||
while (getline(cin, S)) { | ||
if (done) cout << "\n"; | ||
done = true; | ||
|
||
int N = (int) S.size(); | ||
|
||
memset(F, 0, sizeof(F)); | ||
|
||
for (int i = 0; i < N; i++) { | ||
F[(int) S[i]] += 1; | ||
} | ||
|
||
vector<pair<int, int> > ans; | ||
|
||
for (int i = 32; i <= 128; i++) { | ||
if (F[i]) { | ||
ans.push_back(make_pair(F[i], i)); | ||
} | ||
} | ||
|
||
sort(ans.begin(), ans.end(), st); | ||
|
||
for (int i = 0; i < (int) ans.size(); i++) { | ||
cout << ans[i].second << " " << ans[i].first << "\n"; | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
1 | ||
3 | ||
Fred Barney | ||
Barney Betty | ||
Betty Wilma | ||
1234567890 |