結果
問題 | No.1439 Let's Compare!!!! |
ユーザー |
![]() |
提出日時 | 2022-10-02 17:01:03 |
言語 | C (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,423 bytes |
コンパイル時間 | 1,388 ms |
コンパイル使用メモリ | 29,184 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-25 12:50:25 |
合計ジャッジ時間 | 4,436 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 RE * 3 |
ソースコード
#include<stdio.h>int h[200005], l;int comp_h(int a, int b){if (h[a] > h[b])return 1;elsereturn -1;}void swap_h(int a, int b){int f = h[a];h[a] = h[b];h[b] = f;return;}void push(int ne){h[l] = ne;int p = l;l++;for (; p > 0; p = (p - 1) / 2)if (comp_h((p - 1) / 2, p) > 0)swap_h((p - 1) / 2, p);return;}int pop(){l--;swap_h(0, l);int p = 0;for (;;){if (2 * p + 2 < l){if (comp_h(2 * p + 1, 2 * p + 2) > 0){if (comp_h(p, 2 * p + 2) > 0)swap_h(p, 2 * p + 2);p = 2 * p + 2;}else{if (comp_h(p, 2 * p + 1) > 0)swap_h(p, 2 * p + 1);p = 2 * p + 1;}}else if (2 * p + 1 < l){if (comp_h(p, 2 * p + 1) > 0)swap_h(p, 2 * p + 1);p = 2 * p + 1;}elsebreak;}return h[l];}char s[200005], t[200005];int main(){int n;scanf("%d", &n);scanf("%s%s", s, t);int q;scanf("%d", &q);char c[4];int x, y;int i, j, k;l = 0;for (i = 0; i < n; i++){if (s[i] != t[i])push(i);}for (i = 0; i < q; i++){scanf("%s %d %d", &c, &x, &y);x--;if (c[0] == 'S')s[x] = '0' + y;elset[x] = '0' + y;if (s[x] != t[x])push(x);k = -1;while (l > 0){j = pop();if (s[j] != t[j]){k = j;push(j);break;}}if (k < 0)printf("=\n");else if (s[k] < t[k])printf("<\n");elseprintf(">\n");}return 0;}