QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#628376#7716. Average ValueAfterlife#RE 0ms0kbC++204.5kb2024-10-10 19:54:442024-10-10 19:54:44

Judging History

你现在查看的是最新测评结果

  • [2024-10-10 19:54:44]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-10 19:54:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
pii run(pii s,int n,int sx,int step) {
    pii ans = s;
    step %= (n * 2);
    if(s.first == sx) {
        ans.second += step ;
    }
    else {
        ans.second -= step ;
    }
    while(ans.second < 0 || ans.second >= n) {
        if(ans.second < 0) {
            int st = -ans.second - 1;
            ans.second = st;
            ans.first ^= 1;
        }
        if(ans.second >= n) {
            int st = ans.second - n;
            ans.second = n - 1 - st ;
            ans.first ^= 1;
        }
        // printf("%d %d\n",ans.second , n) ;
    }
    return ans;
}
namespace inter {
    mt19937 rnd(0);
    int n , r , c , turn , sx , _r , _c; 
    void init() {
        // n = rnd()%9 + 2;
        // r = rnd()%2;
        // c = rnd()%n ;
        // sx = rnd()%2;
        n = 9 , r = 1 , c = 7 , sx = 1;
        printf("init %d %d %d %d\n",n,r,c,sx) ;
        _r = r ; _c = c;
        turn = 0;
    }
    pii qry(int a,int b = 0)  {
        // printf("Q %d %d\n",a,b) ;
        if(a == 0) {
            if(c == 0) {turn |= 1 ; return {-1,-1};}
            c-- ;
            return {r,c};
        }
        if(a == 1) {
            if(c == n - 1) {turn |= 2 ;  return {-1,-1} ;}
            c++ ;
            return {r,c};
        }
        if(a == 2) {
            r ^= 1;
            return {r,c} ;
        }
        pii ans = run({r , c} , n , sx , b) ;
        r = ans.first ; c = ans.second ;
        // printf("res %d %d\n",r , c);
        return ans ;
    }
    void cls() {
         r=_r ; 
         c = _c;
    }
}
pii qry(int a,int b = 0) {
    // if(a == 0) cout << "left" << endl ;
    // else if(a == 1) cout << "right" << endl ;
    // else if(a == 2) cout << "switch" << endl ;
    // else {
    //     cout << "wait " << b << endl ;
    // }
    // string p ; cin >> p;
    // if(p == "yes") return {-1,-1} ;
    // int x,y;cin >> x >> y;
    // return {x,y};
    return inter::qry(a , b) ;
}
int make(pii a,pii b,int sx,int t) {
    int res;
    if(a.first == b.first) {
        if((a.first == sx)) {res = b.second - a.second ;}
        else res = a.second - b.second ;
    }
    else {
        if((a.first == sx)) res = b.second + a.second - 1;
        else res = b.second + a.second + 1;
    }
    // printf("res %d , %d %d %d %d\n",res , a.first , a.second , b.first , b.second) ;
    return t - res ;
}
void test() {

    int r , c ; 
    // cin >> r >> c;
    inter::init() ; r = inter::r ; c = inter::c ;

    int t1 = 100;
    pii p1 = {r , c} ;
    pii p2 = qry(3 , t1) ;
    pii p3 = qry(3 , 1) ;
    int n = -1;
    int sx = -1; /// sx == 0 , shun , sx == 1 , ni
    if(p2.first == p3.first) {
        if(p3.second > p2.second) {
            pii p4 = qry(2);
            pii p5 = qry(3 , p4.second) ;
            pii p6 = qry(0) ;
            sx = p2.first;
            assert(p6.first == -1 );
        }
        else {
            pii p5 = qry(3 , p3.second) ;
            pii p6 = qry(0) ;
            sx = 1 - p2.first;
            assert(p6.first == -1) ;
        }
    }
    else {
        if(p3.second == 0) {
            sx = p3.first;
            pii p6 = qry(0) ;
            assert(p6.first == -1);
        }
        else {
            sx = 1 - p3.first ;
            n = p3.second + 1;
            pii p5 = qry(3 , n - 1) ;
            pii p6 = qry(0);
            assert(p6.first == -1) ;
        }
    }

    inter::cls() ;

    vector<int> v;
    printf("sx %d\n",sx) ;
    for(int g = 2 ;g <= 1000;g++) {
        if(run(p1 ,g , sx , t1) == p2) v.push_back(g);
    }
    for(auto x : v) printf("%d ",x) ; printf("\n");

    int t2;
    for(t2 = 2 ; t2 <= 1001 ; t2++) {
        map<pii,int> mp;
        bool ff = 1;
        for(auto x : v) {
            pii pos = run(p1 , x , sx , t2) ;
            if(mp.count(pos)) {ff = 0 ;break ;}
            mp[pos] = x;
        }
        if(!ff) continue ;
        pii p2 = qry(3 , t2) ;
        n = mp[p2] ;
        for(int g = 0 ; g <= n * 2;g++) {
            pii pos = run(p2 , n , sx , g) ;
            if(pos.second == n - 1) {
                pii p3 = qry(3 , g) ;
                pii p4 = qry(1) ;
                assert(p4.first == -1) ;
                assert(inter::turn == 3) ;
                return ;
            }
        }
    }
    assert(0) ;
    return ;
}
int main() {
    while(1) {
        test() ;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

5
2 4 8 16 32

output:


result: