QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#386672#5108. Prehistoric ProgramsEnergy_is_not_over#Compile Error//C++172.1kb2024-04-11 19:16:432024-04-11 19:16:45

Judging History

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

  • [2024-04-11 19:16:45]
  • 评测
  • [2024-04-11 19:16:43]
  • 提交

answer

//
// Stvoreno ENERGom o 11.04.24. 13:07:56
//

#include <bits/stdc++.h>

#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define F first
#define fir first
#define S second
#define sec second
#define mp make_pair
#define MP make_pair
#define pb push_back
#define PB push_back

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

#ifdef Energy
#define DEBUG for (int _____DEBUG=1;_____DEBUG;_____DEBUG=0)

template<class ...Ts>
auto &PRNT(Ts ...ts) { return ((cerr << ts << " "), ...); }

#define LOG(...) PRNT(#__VA_ARGS__" ::",__VA_ARGS__)<<endl
#else
#define DEBUG while (0)
#define LOG(...)
#endif

const int max_n = 1e4+10, inf = 1000111222;

pair<int,pii> ttt[max_n];

int m,n,q;

int get_res(int id,int k)
{
    if (k>m){
        return -1;
    }
    if (id==1){
        return (k<=m ? k : -1);
    }

    if (ttt[id].fir==1){
        const int id_there=(ttt[id].sec.sec==0 ? 2*k-1 : 2*k);
        return get_res(ttt[id].sec.fir,id_there);
    }
    else{
        if (k%2==0){
            return get_res(ttt[id].sec.sec,k/2);
        }
        else{
            return get_res(ttt[id].sec.fir,(k+1)/2);
        }
    }
}

int main() {
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>m>>n>>q;
    for (int i=0;i<n;i++){
        char type;
        cin>>type;
        int x,y,z;
        cin>>x>>y>>z;
        if (type=='S'){
            ttt[y]=mp(1,mp(x,0));
            ttt[z]=mp(1,mp(x,1));
        }
        else if (type=='M'){
            ttt[z]=mp(2,mp(x,y));
        }
        else{
            assert(0);
        }
    }
    for (int i=0;i<q;i++){
        int id,k;
        cin>>id>>k;
        int res=get_res(id,k);
        if (res==-1){
            cout<<"none"<<"\n";
        }
        else{
            cout<<res<<"\n";
        }
    }

    exit(0);
}


/home/icpc/workspace/WF/WF21/cmake-build-debug/WF21
2 3 3
S 1 2 3
S 3 4 5
M 5 2 6
3 1
5 1
6 2
2
none
1

Process finished with exit code 0

详细

answer.code:104:1: error: expected unqualified-id before ‘/’ token
  104 | /home/icpc/workspace/WF/WF21/cmake-build-debug/WF21
      | ^