头像

_Ex1le




离线:10小时前


最近来访(23)
用户头像
风不会停息_6
用户头像
trudbot
用户头像
破败之咒不可断绝生生不息
用户头像
19862115019
用户头像
苏钰湫
用户头像
朱星星
用户头像
林笠可
用户头像
你能浇浇我吗
用户头像
爱吸猫的软软
用户头像
梦小洛
用户头像
黎笑涵
用户头像
Codiplay
用户头像
slight
用户头像
巷港
用户头像
前方
用户头像
嗝_7

活动打卡代码 AcWing 4278. 峰会

_Ex1le
5天前
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std ;

const int N = 208 ; 
bool vis[N][N] ; 
int n , m ; 

void solve(const vector<int>& num){
    for(int i = 0 ; i < num.size() - 1 ; i ++) {
        for(int j = i + 1 ; j < num.size() ; j ++) {
            if(!vis[num[i]][num[j]]) {
                cout << "needs help." << '\n' ; 
                return ; 
            }
        }
    }
    for(int i = 1 ; i <= n ; i ++) {
        int j ; 
        for(j = 0 ; j < num.size() ; j ++) {
            if(!vis[i][num[j]]) break ; 
        }
        if(j == num.size()) {cout << "may invite more people, such as " << i << "." << '\n' ; 
        return ; 
        }
    }
    cout << "is OK." << '\n' ; 
}
int main(){
    cin >> n >> m ; 
    int a , b; 
    while(m --){
        cin >> a >> b ; 
        vis[a][b] = vis[b][a] = true ; 
    }
    int k ; 
    cin >> k ;
    vector<int>num ; 
    for(int i = 1 ; i <= k ; i ++){
        num.clear() ; 
        int l ; 
        cin >> l ; 
        int x ; 
        while(l --) {
            cin >> x ; 
            num.push_back(x) ; 
        }
        cout << "Area " << i << ' ' ; 
        solve(num) ; 
    }
    return 0 ; 
}


活动打卡代码 AcWing 4269. 校庆

_Ex1le
6天前
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_set>

using namespace std ;
int n , m ; 
unordered_set<string> se ;
string s ; 
int main(){
    cin >> n ; 
    for(int i = 0 ; i < n ; i ++) {
        cin >> s ; 
        se.insert(s) ; 
    }
    cin >> m ; 
    bool flag = false ; 
    string a , b ; 
    int ans = 0 ; 
    for(int i = 0 ; i < m ; i ++) {
        cin >> s ; 
        if(se.count(s)){
            flag = true ; 
            ans ++ ; 
            if(a.empty() || a.substr(6 , 8) > s.substr(6 , 8)) a = s ; 
        }
        if(b.empty() || b.substr(6 , 8) > s.substr(6 , 8)) b = s ; 
    }
    cout << ans << '\n' ; 
    if(flag) cout << a << '\n' ; 
    else cout << b << '\n' ; 

    return 0 ;
}


活动打卡代码 AcWing 4268. 性感素数

_Ex1le
9天前
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define inf 0x3f3f3f3f

using namespace std ;

bool judge(int x){
    if(x <= 1) return false ; 
    else {
        for(int i = 2 ; i <= sqrt(x) ; i ++) {
            if(x % i == 0) return false ; 
        }
        return true ; 
    }
}

int main(){
    std::ios::sync_with_stdio(false) ; 
    std::cin.tie(0) ;

    int n ; 
    cin >> n ; 
    if(judge(n) && (judge(n - 6) || judge(n + 6))) {
        cout << "Yes" << '\n' ; 
        if(judge(n - 6)) cout << n - 6 << '\n' ; 
        else cout << n + 6 << '\n' ; 
    }
    else {
        cout << "No" << '\n' ; 
        for(int i = n + 1 ; ; i ++){
            if(judge(i) && (judge(i - 6) || judge(i + 6))) {
                cout << i << '\n' ; 
                break ; 
            }
        }
    }

    return 0 ; 
}


活动打卡代码 AcWing 2048. 干草

_Ex1le
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 10010;

int n;
int h[N];

int main()
{
    cin >> n;

    int sum = 0;
    for (int i = 0; i < n; i ++ )
    {
        cin >> h[i];
        sum += h[i];
    }

    int height = sum / n;
    int res = 0;

    for (int i = 0; i < n; i ++ )
        if (h[i] < height)
            res += height - h[i];

    cout << res << endl;

    return 0;
}



活动打卡代码 AcWing 2057. 比赛时间

_Ex1le
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int d, h, m;
    cin >> d >> h >> m;

    int a = 11 * 1440 + 11 * 60 + 11;
    int b = d * 1440 + h * 60 + m;

    if (a > b) puts("-1");
    else cout << b - a << endl;

    return 0;
}


活动打卡代码 AcWing 1968. 奶牛赛跑

_Ex1le
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 1000010;

int n, m;
int a[N], b[N];

int main()
{
    cin >> n >> m;

    int t = 0;
    while (n -- )
    {
        int x, y;
        cin >> x >> y;
        while (y -- )
        {
            t ++ ;
            a[t] = a[t - 1] + x;
        }
    }

    t = 0;
    while (m -- )
    {
        int x, y;
        cin >> x >> y;
        while (y -- )
        {
            t ++ ;
            b[t] = b[t - 1] + x;
        }
    }

    int res = 0;
    for (int i = 1, k = 0; i <= t; i ++ )
        if (a[i] > b[i])
        {
            if (k == 2) res ++ ;
            k = 1;
        }
        else if (a[i] < b[i])
        {
            if (k == 1) res ++ ;
            k = 2;
        }

    cout << res << endl;
    return 0;
}



活动打卡代码 AcWing 1977. 信息中继

_Ex1le
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 1010;

int n;
int p[N], f[N];

int find(int x)
{
    if (p[x] != x) p[x] = find(p[x]);
    return p[x];
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i ++ ) p[i] = i;

    for (int i = 1; i <= n; i ++ )
    {
        cin >> f[i];
        if (f[i]) p[find(i)] = find(f[i]);
    }

    int res = 0;
    for (int i = 1; i <= n; i ++ )
    {
        int r = find(i);
        if (!f[r]) res ++ ;
    }

    cout << res << endl;
    return 0;
}


活动打卡代码 AcWing 1995. 见面与问候

_Ex1le
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 1000010;

int n, m;
int a[N], b[N];

int main()
{
    scanf("%d%d", &n, &m);

    int t = 0;
    while (n -- )
    {
        int l;
        char d;
        scanf("%d %c", &l, &d);
        int v = 1;
        if (d == 'L') v = -1;

        while (l -- )
        {
            t ++ ;
            a[t] = a[t - 1] + v;
        }
    }
    while ( ++ t < N) a[t] = a[t - 1];


    t = 0;
    while (m -- )
    {
        int l;
        char d;
        scanf("%d %c", &l, &d);
        int v = 1;
        if (d == 'L') v = -1;

        while (l -- )
        {
            t ++ ;
            b[t] = b[t - 1] + v;
        }
    }
    while ( ++ t < N) b[t] = b[t - 1];

    int res = 0;
    for (int i = 1; i < N; i ++)
        if (a[i] == b[i] && a[i - 1] != b[i - 1])
            res ++ ;

    printf("%d\n", res);
    return 0;
}



活动打卡代码 AcWing 1912. 里程表

_Ex1le
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long LL;

int main()
{
    LL x, y;

    cin >> x >> y;

    int res = 0;
    for (int i = 3; i <= 17; i ++ )
        for (int j = 0; j < 10; j ++ )
            for (int k = 0; k < 10; k ++ )
                if (k != j)
                    for (int u = 0; u < i; u ++ )
                    {
                        string str(i, '0' + j);
                        str[u] = '0' + k;
                        if (str[0] != '0')
                        {
                            LL v = stoll(str);
                            if (v >= x && v <= y)
                                res ++ ;
                        }
                    }

    cout << res << endl;
    return 0;
}



活动打卡代码 AcWing 1921. 重新排列奶牛

_Ex1le
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 110;

int n;
int a[N], b[N], p[N], s[N];

int find(int x)
{
    if (p[x] != x) p[x] = find(p[x]);
    return p[x];
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i ++ ) cin >> a[i];
    for (int i = 1; i <= n; i ++ )
    {
        int x;
        cin >> x;
        b[x] = i;
    }
    for (int i = 1; i <= n; i ++ ) p[i] = i, s[i] = 1;

    for (int i = 1; i <= n; i ++ )
    {
        int x = a[i], y = a[b[x]];
        if (find(x) != find(y))
        {
            s[find(y)] += s[find(x)];
            p[find(x)] = find(y);
        }
    }

    int cnt = 0, mx = 0;
    for (int i = 1; i <= n; i ++ )
        if (p[i] == i && s[i] > 1)
        {
            cnt ++ ;
            mx = max(mx, s[i]);
        }

    if (!cnt) mx = -1;
    cout << cnt << ' ' << mx << endl;
    return 0;
}