結果
問題 | No.145 yukiover |
ユーザー | Onju |
提出日時 | 2015-02-06 01:12:43 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,157 bytes |
コンパイル時間 | 641 ms |
コンパイル使用メモリ | 68,308 KB |
実行使用メモリ | 8,576 KB |
最終ジャッジ日時 | 2024-06-23 09:54:59 |
合計ジャッジ時間 | 7,340 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 35 ms
5,376 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
ソースコード
#include <iostream> #include <algorithm> #include <functional> #include <climits> #include <cstring> #include <string> #define N_MAX 100000 #define USED '\0' using namespace std; bool comp(const char&x, const char&y) { if (x == '\0') return false; else if (y == '\0') return true; else return x < y; } int main() { int N, ans = 0; char S[N_MAX + 1]; cin >> N >> S; bool find; //ごり押してみる ikuy sort(S, S + N,comp); for (int i = 0; i < N; ++i, find = true) { if (S[i] == 'y') for (int j = 0; j < N && find; ++j) if (S[j] == 'u' && S[j] < 'y') for (int k = 0; k < N && find; ++k) if (S[k] == 'k' && S[k] < 'u') for (int l = 0; l < N && find; ++l) if (S[l] == 'i' && S[l] < 'k') for (int m = 0; m < N && find; ++m) { if (m == i || m == j || m == k || m == l) continue; else if (S[m] != USED && S[m] < 'i') { S[m] = S[l] = S[k] = S[j] = S[i] = USED; ++ans; find = false; } } } sort(S, S + N, comp); N = strlen(S); for (int i = 0; i < N; ++i, find = true) { if (S[i] == 'y') for (int j = 0; j < N && find; ++j) if (S[j] == 'u' && S[j] < 'y') for (int k = 0; k < N && find; ++k) if (S[k] == 'k' && S[k] < 'u') for (int l = 0; l < N && find; ++l) { if (l == i || l == j || l == k) continue; else if (S[l] > 'i' && S[l] < 'k') { ++ans; S[l] = S[k] = S[j] = S[i] = USED; find = false; } } } sort(S, S + N, comp); N = strlen(S); for (int i = 0; i < N; ++i, find = true) { if (S[i] == 'y') for (int j = 0; j < N && find; ++j) if (S[j] == 'u' && S[j] < 'y') for (int k = 0; k < N && find; ++k) { if (k == i || k == j) continue; else if (S[k] > 'k' && S[k] < 'u') { ++ans; S[k] = S[j] = S[i] = USED; find = false; } } } sort(S, S + N, comp); N = strlen(S); for (int i = 0; i < N; ++i, find = true) { if (S[i] == 'y') for (int j = 0; j < N && find; ++j) { if (j == i) continue; else if (S[j] > 'u' && S[j] < 'y') { ++ans; S[j] = S[i] = USED; find = false; } } } sort(S, S + N, comp); N = strlen(S); for (int i = 0; i < N; ++i) if (S[i] > 'y') { ++ans; S[i] = USED; } sort(S, S + N, comp); N = strlen(S); for (int i = 0; i < N; ++i, find = true) { if (S[i] == 'y') for (int j = 0; j < N && find; ++j) if (S[j] == 'u') for (int k = 0; k < N && find; ++k) if (S[k] == 'k') for (int l = 0; l < N && find; ++l) if (S[l] == 'i') for (int m = 0; m < N && find; ++m) { if (m == i || m == j || m == k || m == l) continue; else if (S[m] != USED) { S[m] = S[l] = S[k] = S[j] = S[i] = USED; ++ans; find = false; } } } sort(S, S + N, comp); N = strlen(S); for (int i = 0; i < N; ++i, find = true) { if (S[i] == 'y') for (int j = 0; j < N && find; ++j) if (S[j] == 'u') for (int k = 0; k < N && find; ++k) if (S[k] == 'k') for (int l = 0; l < N && find; ++l) { if (l == i || l == j || l == k) continue; else if (S[l] > 'i') { ++ans; S[l] = S[k] = S[j] = S[i] = USED; find = false; } } } sort(S, S + N, comp); N = strlen(S); for (int i = 0; i < N; ++i, find = true) { if (S[i] == 'y') for (int j = 0; j < N && find; ++j) if (S[j] == 'u') for (int k = 0; k < N && find; ++k) { if (k == i || k == j) continue; else if (S[k] > 'k') { ++ans; S[k] = S[j] = S[i] = USED; find = false; } } } sort(S, S + N, comp); N = strlen(S); for (int i = 0; i < N; ++i, find = true) { if (S[i] == 'y') for (int j = 0; j < N && find; ++j) { if (j == i) continue; else if (S[j] > 'u') { ++ans; S[j] = S[i] = USED; find = false; } } } cout << ans; return 0; }