fork download
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define int long long
  7. #define nn "\n"
  8. #define pi pair<int, int>
  9. #define fi first
  10. #define se second
  11. #define lb lower_bound
  12. #define ub upper_bound
  13. #define eb emplace_back
  14. #define pb push_back
  15. #define TASK " "
  16.  
  17. #define ms(a, x) memset(a, x, sizeof(a))
  18. #define all(a) a.begin(), a.end()
  19. #define All(a, n) a + 1, a + 1 + n
  20.  
  21. #define LOG 19
  22.  
  23.  
  24. const int INF = 1e18;
  25. const int mod = 1e9+7;
  26. const int N = 2e5 + 5;
  27. const int maxN = 4e5 + 5;
  28. int MOD = 998244353;
  29. int bit[200000];
  30. struct node{
  31. int kc, u, hk;
  32. bool operator<(const node& other) const {
  33. return kc > other.kc;
  34. }
  35. };
  36. struct edge{
  37. int v, w, h;
  38. };
  39. string s;
  40. void nhap(){
  41.  
  42. }
  43. void solve(){
  44. while(cin >> s){
  45. if(s == "0") break;
  46. bool ok = 1;
  47. for(int i = 0; i < s.size(); i++){
  48. if(s[i] != '(' && s[i] != ')'){
  49. cout << "KHONGHOPLE" << nn;
  50. ok = 0;
  51. break;
  52. }
  53. }
  54. int kq = 0;
  55. for(int i = 0; i < s.size(); i++){
  56. if(s[i] == '('){
  57. kq++;
  58. }
  59. else{
  60. kq--;
  61. }
  62. }
  63. if(kq != 0 && ok){
  64. cout << "KHONGDUNG" << nn;
  65. }
  66. else if(ok && kq == 0) cout << "DUNG" << nn;
  67. }
  68. }
  69. // nGuyEn Le truOng thanH
  70. signed main() {
  71. // freopen("CHUANHOA.INP", "r", stdin);
  72. // freopen("CHUANHOA.OUT", "w", stdout);
  73. ios_base::sync_with_stdio(0);
  74. cin.tie(0);
  75. cout.tie(0);
  76. solve();
  77. return (0 ^ 0);
  78.  
  79. }
  80.  
  81.  
Success #stdin #stdout 0s 5324KB
stdin
(((abc))
((()()))()
(()(()()))))
stdout
KHONGHOPLE
DUNG
KHONGDUNG