能过样例但0分,求路过的大神纠正
查看原帖
能过样例但0分,求路过的大神纠正
681982
isxi楼主2023/7/23 18:04
#include "bits/stdc++.h"
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef map<int,int> MII;
typedef map<long ,long > MLL;
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(u) u.begin(), u.end()
#define debug(x) cout<<#x<<":"<<x<<endl;

const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10, M = 105;
const int mod = 1e9 + 7;
const int cases = 0;
int f[1005],b[1005];
void solve(){
    // vector<int>f;
    int x;
    int tmp=0;
    int idx=1;
    while(cin>>x){
        f[idx]=x;
        b[idx++]=x-tmp-1;
        tmp=x;
    }
    idx--;
    int ans=0;
    // for(int i=1;i<=idx;i++) cout<<b[i]<<" "<<endl;
    for(int i=1;i<=idx;i+=2){
        // cout<<b[i]<<endl;
        ans^=b[i];
    }
    if(!ans){
        cout<<"-1"<<endl;return;
    }
    for(int i=1;i<=idx;i++){
        if((b[i]^ans)<=b[i]) continue;
        cout<<f[i]<<" "<<f[i]+(b[i]^ans)-b[i]<<endl;
        break;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
	int t=1;
    if(cases)
		cin>>t;
	while(t--){
		solve();
	}
	return 0;
} 
  

能过样例但0分,最后移动的思路来自于b站董晓算法,求纠正

2023/7/23 18:04
加载中...