zoukankan      html  css  js  c++  java
  • Testing Round #16 (Unrated)

    比赛链接:https://codeforces.com/contest/1351

    A - A+B (Trial Problem)

    #include <bits/stdc++.h>
    using namespace std;
    
    void solve() {
        int a, b; cin >> a >> b;
        cout << a + b << "
    ";
    }
    
    int main() {
        int t; cin >> t;
        while (t--) solve();
    }

    B - Square?

    #include <bits/stdc++.h>
    using namespace std;
    
    void solve() {
        int a1, b1, a2, b2; cin >> a1 >> b1 >> a2 >> b2;
        if (a1 > b1) swap(a1, b1);
        if (a2 > b2) swap(a2, b2);
        if (a1 + a2 == b1 and b1 == b2) cout << "YES" << "
    ";
        else cout << "NO" << "
    ";
    }
    
    int main() {
        int t; cin >> t;
        while (t--) solve();
    }

    C - Skier

    #include <bits/stdc++.h>
    using namespace std;
    
    void solve() {
        string s; cin >> s;
        map<pair<pair<int, int>, pair<int, int>>, bool> mp;
        pair<int, int> pr{0, 0};
        int ans = 0;
        for (char c : s) {
            pair<int, int> pr0 = pr;
            if (c == 'N') pr.second++;
            else if (c == 'S') pr.second--;
            else if (c == 'W') pr.first--;
            else pr.first++;
            pair<pair<int, int>, pair<int, int>> p1 = make_pair(pr0, pr);
            pair<pair<int, int>, pair<int, int>> p2 = make_pair(pr, pr0);
            if (mp[p1] or mp[p2]) ++ans;
            else mp[p1] = mp[p2] = true, ans += 5;
        }
        cout << ans << "
    ";
    }
    
    int main() {
        int t; cin >> t;
        while (t--) solve();
    }

    我这也算是在线 ak 过一场 cf 了吧 =。=

  • 相关阅读:
    141. Linked List Cycle【easy】
    237. Delete Node in a Linked List【easy】
    234. Palindrome Linked List【easy】
    排序_归并排序
    排序_选择排序
    排序_快速排序
    排序_冒泡排序
    排序_希尔排序
    排序_插入排序
    121. Best Time to Buy and Sell Stock【easy】
  • 原文地址:https://www.cnblogs.com/Kanoon/p/12846922.html
Copyright © 2011-2022 走看看