CF 168(div2)

A.直接模拟即可,最后根据翻转次数奇偶判断。

B.类似连连看的判断,要求判断任意两点间是否能最多只转一次方向就相连。对每一点,先拓展出和它相同行,相同列能连到的点,再对那些点再做一次拓展,记录下总共能到达的点数目,判断是否为总点数即可。代码比较挫

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <cmath>
using namespace std;
const int maxn = 50 + 5;
const int INF = 1000000000;
typedef long long LL;

char M[maxn][maxn];
int vis[maxn][maxn];
struct Node{
    int x,y;
};

int n,m;
queue<Node> Q;

int Bfs(int x,int y){
    memset(vis,0,sizeof(vis));
    while(!Q.empty()) Q.pop();
    int ret = 1;
    for(int i = y+1;i < m;i++){
        if(M[x][i] == 'B'){
            Q.push(Node{x,i});
            if(vis[x][i] == 0){
                ret++;
                vis[x][i] = 1;
            }
        }
        else break;
    }
    for(int i = y-1;i >= 0;i--){
        if(M[x][i] == 'B'){
            Q.push(Node{x,i});
            if(vis[x][i] == 0){
                vis[x][i] = 1;
                ret++;
            }
        }
        else break;
    }
    while(!Q.empty()){
        int X = Q.front().x;
        int Y = Q.front().y;
        Q.pop();
        for(int i = X-1;i >= 0;i--){
            if(M[i][Y] == 'B'){
                if(vis[i][Y] == 0){
                    ret++;
                    vis[i][Y] = 1;
                }
            }
            else break;
        }
        for(int i = X+1;i < n;i++){
            if(M[i][Y] == 'B'){
                if(vis[i][Y] == 0){
                    vis[i][Y] = 1;
                    ret++;
                }
            }
            else break;
        }
    }

    while(!Q.empty()) Q.pop();
    for(int i = x+1;i < n;i++){
        if(M[i][y] == 'B'){
            Q.push(Node{i,y});
            if(vis[i][y] == 0){
                vis[i][y] = 1;
                ret++;
            }
        }
        else break;
    }
    for(int i = x-1;i >= 0;i--){
        if(M[i][y] == 'B'){
            Q.push(Node{i,y});
            if(vis[i][y] == 0){
                vis[i][y] = 1;
                ret++;
            }
        }
        else break;
    }
    while(!Q.empty()){
        int X = Q.front().x;
        int Y = Q.front().y;
        Q.pop();
        for(int i = Y-1;i >= 0;i--){
            if(M[X][i] == 'B'){
                if(vis[X][i] == 0){
                    vis[X][i] = 1;
                    ret++;
                }
            }
            else break;
        }
        for(int i = Y+1;i < m;i++){
            if(M[X][i] == 'B'){
                if(vis[X][i] == 0){
                    vis[X][i] = 1;
                    ret++;
                }
            }
            else break;
        }
    }
    return ret;
}

int main(){
    while(cin >> n >> m){
        int total = 0;
        for(int i = 0;i < n;i++) scanf("%s",M[i]);
        for(int i = 0;i < n;i++){
            for(int j = 0;j < m;j++)
                if(M[i][j] == 'B') total++;
        }
        int ans = 1;
        for(int i = 0;i < n;i++){
            for(int j = 0;j < m;j++){
                if(M[i][j] == 'B' && Bfs(i,j) != total){
                    //printf("%d %d %d\n",i,j,Bfs(i,j));
                    ans = 0;
                    break;
                }
            }
            if(ans == 0) break;
        }
        if(ans == 0) cout << "NO\n";
        else cout << "YES\n";
    }
    return 0;
}


C.贪心的做法,从小到大排序后,优先选小的,然后把这个数a*k的值标记为不能选的,因为数的范围很大,用个map即可。

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <cmath>
using namespace std;
const int maxn = 100000 + 5;
const int INF = 1000000000;
typedef long long LL;

LL a[maxn];
map<LL,bool> M;

int main(){
    int n;
    LL k;
    while(cin >> n >> k){
        for(int i = 0;i < n;i++) cin >> a[i];
        sort(a,a+n);
        M.clear();
        int ans = 0;
        for(int i = 0;i < n;i++){
            if(M.count(a[i]) == 0){
                ans++;
                M[a[i]*k] = true;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


 

(venv) gapinyc@DESKTOP-9QS7RL5:~/superset-kiosk$ # 提取 access_token ACCESS_TOKEN=$(echo $RESPONSE | sed -n 's/.*"access_token":"\([^"]*\)".*/\1/p') # 从 JWT payload 中提取 csrf 字段 decode_jwt_payload() { local jwt="$1" local payload=$(echo "$jwt" | cut -d'.' -f2) # 取第二段 local padded=$(echo "$payload" | sed -e 's/_/-/g' -e 's/\./+/g') # Base64URL → standard local mod4=$((${#padded} % 4)) if [ $mod4 -eq 2 ]; then padded="${padded}==" elif [ $mod4 -eq 3 ]; then padded="${padded}=" fi echo "$padded" | base64 -d 2>/dev/null # 解码 } # 解码并提取 csrf CSRF_TOKEN=$(decode_jwt_payload "$ACCESS_TOKEN" | sed -n 's/.*"csrf":"\([^"]*\)".*/\1/p') echo "Access Token: $ACCESS_TOKEN" echo "CSRF Token : $CSRF_TOKEN" Access Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6dHJ1ZSwiaWF0IjoxNzYxNzQ1MTc0LCJqdGkiOiJiODcyMWJkMi0xN2EwLTRhMzYtYWM0NC04OWMwNDUxNTYxMzQiLCJ0eXBlIjoiYWNjZXNzIiwic3ViIjoiMSIsIm5iZiI6MTc2MTc0NTE3NCwiY3NyZiI6ImNmN2VhNjIzLTBhZGQtNDFhYy04ZDM1LThiNTRlOGQyOTJiZSIsImV4cCI6MTc2MTc0NjA3NH0.Xdop3mFtDgvH0UOG76f2JfJd7i_eZXT0U8-LPytAEQE CSRF Token : cf7ea623-0add-41ac-8d35-8b54e8d292be (venv) gapinyc@DESKTOP-9QS7RL5:~/superset-kiosk$ curl -X POST \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -H "X-CSRFToken: $CSRF_TOKEN" \ -d '{ "object_type": "dashboard", "object_id": 2, "tag_names": ["kiosk"] }' \ http://192.168.110.204:8088/api/v1/tag/_bulk_tags/ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=q,initial-scale=1"/><link rel="icon" type="image/png" href="/static/assets/e3bafb62eb2592c0bb0e.png"/><link rel="preconnect" href="https://fonts.gstatic.com"/><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap" rel="stylesheet"/><style>html { height: 100%; } body { color: #1985a0; font-family: 'Inter', sans-serif; height: 100%; margin: 0; display: flex; align-items: stretch; } h1 { font-weight: 600; font-size: 88px; margin: 0; } p { font-weight: 500; font-size: 24px; line-height: 40px; width: 490px; } .button { -webkit-appearance: button; -moz-appearance: button; appearance: button; background-color: #1985a0; /* Green */ border: none; color: white; padding: 16px 38px; text-align: center; text-decoration: none; display: inline-block; font-size: 11px; border-radius: 4px; text-transform: uppercase; } .error-page-content { display: flex; flex-direction: row; align-items: center; justify-content: space-between; max-width: 1350px; margin: auto; width: 100%; padding: 56px; } img { width: 540px; }</style><title>404: Not found | Superset</title></head><body><div class="error-page-content"><section><h1>Page not found</h1><p>Sorry, we cannot find the page you are looking for. You may have mistyped the address or the page may have moved.</p><a href="/" class="button">Back to home</a></section><img alt="404" src="/static/assets/1a1474519a0ea853fdce.png" width="540"/></div></body></html>(venv) gapinyc@DESKTOP-9QS7RL5:~/superset-kiosk$
最新发布
10-30
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值