Codeforces Round 944 (Div. 4) My Contest Submissions

Codeforces Round 944 (Div. 4)

A. My First Sorting Problem

n = int(input())
for _ in range(n):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    print(a, b)

B. Different String

n = int(input())
for _ in range(n):
    ss = input()
    if ss == ss[0]*len(ss):
        print("NO")
    else:
        print("YES")
        for i in range(len(ss)-1):
            if ss[i] != ss[i+1]:
                print(ss[:i]+ss[i+1]+ss[i]+ss[i+2:])
                break

C. Clock and Strings

t = int(input())
for _ in range(t):
    a, b, c, d = map(int, input().split())
    if a > b:
        a, b = b, a
    if a<c<b:
        if d>b or d<a:
            print('YES')
        else:
            print('NO')
    elif a<d<b:
        if c>b or c<a:
            print('YES')
        else:
            print('NO')
    else:
        print('NO')

D. Binary Cut

t = int(input())
for _ in range(t):
    ss = input()
    ans = 1
    j = 0
    for i in range(len(ss)-1):
        if ss[i]=='1' and ss[i+1]=='0':
            ans += 1
        if ss[i]=='0' and ss[i+1]=='1':
            ans += 1
            j = 1
    print(ans-j)

E. Find the Car

#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll N = 1e5 + 5;
void solve(){
    ll a[N]={0}, b[N]={0};
    ll n, k, q, d;
    cin >> n >> k >> q;
    for(int i=1; i<=k; i++) cin >> a[i];
    for(int i=1; i<=k; i++) cin >> b[i];
    while(--q){
        cin >> d;
        ll y = upper_bound(a, a+k, d) - a;
        ll x = y-1;
        cout << (ll)b[x]+(d-a[x])*(b[y]-b[x])/(a[y]-a[x]) << ' ';
    }cin >> d;
    ll y = upper_bound(a, a+k, d) - a;
    ll x = y-1;
    cout << (ll)b[x]+(d-a[x])*(b[y]-b[x])/(a[y]-a[x]) << "\n";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while(t--) solve();
}

F. Circle Perimeter

from math import isqrt
t = int(input())
for _ in range(t):
    ans = 0
    r = int(input())
    for i in range(r+1):
        j = isqrt((r+1)**2 - i**2)
        if i**2 + j**2 == (r+1)**2:
            j -= 1
        while(r**2 <= i**2 + j**2):
            ans += 1
            j -= 1
            if j < 0:
                break
    print(ans*4-4)

G. XOUR

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll, priority_queue<ll, vector<ll>, greater<ll>>> mp;
void solve(){
    int n;
    cin >> n;
    ll a[n], b[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
        b[i] = a[i]/4;
        mp[b[i]].push(a[i]);
    }cout << mp[b[0]].top();
    mp[b[0]].pop();
    for(int i=1; i<n; i++){
        cout << " " << mp[b[i]].top();
        mp[b[i]].pop();
    }cout << "\n";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while(t--) solve();
}
  • 9
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jord8061

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值