zoukankan      html  css  js  c++  java
  • Codeforces Round #607 (Div. 2) A、B

    个人做题记录

    今天最近不少心烦事,唉

    A. Suffix Three

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    using namespace std;
    int t;
    char s[1010];
    
    int main() {
        scanf("%d", &t);
        while(t --) {
            scanf("%s", s + 1);
            int n = strlen(s + 1);
            if(s[n] == 'o') cout << "FILIPINO
    ";
            else if(s[n] == 'a') cout << "KOREAN
    ";
            else cout << "JAPANESE
    ";
        }
        
        return 0;
    }
    

    B. Azamon Web Services

    对字典序理解不够,导致做的时候WA了很多次。注意贪心

    #include <bits/stdc++.h>
    using namespace std;
    const int N = 5050;
    int t;
    string s, c;
    
    inline void change() {
        string tmp = s;
        sort(tmp.begin(), tmp.end());
        
        int n = s.length();
        for(int i = 0; i < n; i++) {
            if(s[i] != tmp[i]) {
                for(int j = n - 1;j > i; j--) {
                    if(s[j] == tmp[i]) {
                        swap(s[i], s[j]);
                        return;
                    }
                }
            }
        }
    }
    
    int main() {
        scanf("%d", &t);
        while(t --) {
            cin >> s >> c;
            change();
            if(s < c) cout << s << '
    ';
            else cout << "---" << '
    ';
        }
        
        return 0;
    }
    
  • 相关阅读:
    day13_迭代器,生成器
    作业礼包
    day12_装饰器进阶
    装饰器作业
    day11_装饰器
    函数作业
    day10-函数进阶
    数据类型-习题解答
    day09_函数
    PHP 完美分页
  • 原文地址:https://www.cnblogs.com/FrankOu/p/14521419.html
Copyright © 2011-2022 走看看