• Codeforces Round 900 (Div. 3)


    Codeforces Round 900 (Div. 3)

    Codeforces Round 900 (Div. 3) A. How Much Does Daytona Cost?

    import java.io.*;
    import java.util.ArrayList;
    
    public class Main {
        public static void main(String[] args) throws IOException {
            BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
            int T = Integer.parseInt(bf.readLine());
            while (T-- > 0) {
                String[] str = bf.readLine().split(" ");
                int n = Integer.parseInt(str[0]);
                int k = Integer.parseInt(str[1]);
                str = bf.readLine().split(" ");
                ArrayList<Integer> a = new ArrayList<>();
                for (int i = 0; i < n; i++) {
                    a.add(Integer.parseInt(str[i]));
                }
                if (a.contains(k)) bw.write("YES\n");
                else bw.write("NO\n");
            }
            bw.close();
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23

    Codeforces Round 900 (Div. 3) B. Aleksa and Stack

    import java.io.*;
    
    public class Main {
        public static void main(String[] args) throws IOException {
            BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
            int T = Integer.parseInt(bf.readLine());
            while (T-- > 0) {
                int n = Integer.parseInt(bf.readLine());
                for (int i = 1; i <= n; i++) {
                    bw.write(2 * i - 1 + " ");
                }
                bw.write("\n");
            }
            bw.close();
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    Codeforces Round 900 (Div. 3) C. Vasilije in Cacak

    import java.io.*;
    
    public class Main {
        public static void main(String[] args) throws IOException {
            BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
            int T = Integer.parseInt(bf.readLine());
            while (T-- > 0) {
                String[] str = bf.readLine().split(" ");
                int n = Integer.parseInt(str[0]);
                int k = Integer.parseInt(str[1]);
                long x = Long.parseLong(str[2]);
                long l = (long) (k + 1) * k / 2;
                long r = (2L * n - k + 1) * k / 2;
                if (l <= x && x <= r) bw.write("YES\n");
                else bw.write("NO\n");
            }
            bw.close();
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    Codeforces Round 900 (Div. 3) D. Reverse Madness

    import java.io.*;
    
    public class Main {
        public static void main(String[] args) throws IOException {
            BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
            int T = Integer.parseInt(bf.readLine());
            while (T-- > 0) {
                String[] str = bf.readLine().split(" ");
                int n = Integer.parseInt(str[0]);
                int k = Integer.parseInt(str[1]);
                char[] s = bf.readLine().toCharArray();
                str = bf.readLine().split(" ");
                int[] l = new int[k];
                for (int i = 0; i < k; i++) {
                    l[i] = Integer.parseInt(str[i]);
                    l[i]--;
                }
                str = bf.readLine().split(" ");
                int[] r = new int[k];
                for (int i = 0; i < k; i++) {
                    r[i] = Integer.parseInt(str[i]);
                    r[i]--;
                }
                int q = Integer.parseInt(bf.readLine());
                int[] f = new int[n];
                str = bf.readLine().split(" ");
                for (int i = 0; i < q; i++) {
                    int x = Integer.parseInt(str[i]);
                    x--;
                    f[x] ^= 1;
                }
                for (int i = 0; i < k; i++) {
                    int rev = 0;
                    for (int j = l[i]; j <= l[i] + r[i] - j; j++) {
                        rev ^= f[j] ^ f[l[i] + r[i] - j];
                        if (rev != 0) {
                            char temp = s[j];
                            s[j] = s[l[i] + r[i] - j];
                            s[l[i] + r[i] - j] = temp;
                        }
                    }
                }
                for (int i = 0; i < s.length; i++) bw.write(s[i]);
                bw.write("\n");
            }
            bw.close();
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49

    Codeforces Round 900 (Div. 3) E. Iva & Pav

    import java.io.*;
    import java.util.Arrays;
    
    public class Main {
        public static void main(String[] args) throws IOException {
            BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
            int T = Integer.parseInt(bf.readLine());
            while (T-- > 0) {
                int n = Integer.parseInt(bf.readLine());
                int[] a = new int[n];
                String[] str = bf.readLine().split(" ");
                for (int i = 0; i < n; i++) {
                    a[i] = Integer.parseInt(str[i]);
                }
                int[][] nxt = new int[n + 1][30];
                for (int i = 0; i <= n; i++) Arrays.fill(nxt[i], n);
                for (int i = n - 1; i >= 0; i--) {
                    System.arraycopy(nxt[i + 1], 0, nxt[i], 0, 30);
                    for (int j = 0; j < 30; j++) {
                        if ((~a[i] >> j & 1) == 1) {
                            nxt[i][j] = i;
                        }
                    }
                }
                int q = Integer.parseInt(bf.readLine());
                while (q-- > 0) {
                    str = bf.readLine().split(" ");
                    int l = Integer.parseInt(str[0]);
                    int k = Integer.parseInt(str[1]);
                    l--;
                    int ans = l;
                    int res = n;
                    for (int i = 29; i >= 0; i--) {
                        if ((k >> i & 1) == 1) {
                            res = Math.min(res, nxt[l][i]);
                        } else {
                            ans = Math.max(ans, Math.min(res, nxt[l][i]));
                        }
                    }
                    ans = Math.max(ans, res);
                    if (ans <= l) {
                        ans = -1;
                    }
                    bw.write(ans + " ");
                }
                bw.write("\n");
            }
            bw.close();
        }
    }
    
    /*
    1
    5
    15 14 17 42 34
    1
    4 5
    */
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
  • 相关阅读:
    【C++】C++学习(模板+排序+测时)
    Spring MVC 入门指南
    献给Nacos小白的一篇好文:配置参数使用及存储
    【MATLAB】 04 数值微积分
    优雅而酷炫的自定义CSS滚动条:展示
    【jenkins部署冲突报错】一定要看!!!!!
    学生HTML个人网页作业作品 简单的IT技术个人简历模板html下载 简单个人网页设计作业 静态HTML个人博客主页
    ECK安装elasticsearch集群及es配置x-pack
    eclipse启动tomcat无法访问
    Vue 和 jQuery 两者之间的区别是什么?
  • 原文地址:https://blog.csdn.net/qq_52792570/article/details/133793173