QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#657244#5110. Splitstreamiambotx11WA 1ms3632kbC++142.5kb2024-10-19 14:25:422024-10-19 14:25:42

Judging History

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

  • [2024-10-19 14:25:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3632kb
  • [2024-10-19 14:25:42]
  • 提交

answer

#include<iostream>
#include<string.h>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

struct Node{
  string name;
  int vId1;
  int vId2;
  int vId3;
};

struct Dnode{
  vector<int> vec;
};

bool compare(const Node& p1, const Node& p2) {
    if (p1.name == p2.name) {
        return p1.vId1 < p2.vId1; // If ages are the same, sort by name
    }
    return p1.name > p2.name; // Sort by age
}

int main(){ 
  int m,n,q;
  cout << "Enter values of m, n and q: " << endl;
  cin >> m >> n >> q;
  vector<Node> node(n);
  vector<pair<int, int>> query(q);
  int maxx=1;


  for(int i=0;i<n;i++){
    //cout << "Enter details of Node " << i+1 << endl;
    cin >> node[i].name >> node[i].vId1 >> node[i].vId2 >> node[i].vId3;
    maxx=max({maxx, node[i].vId1 , node[i].vId2 , node[i].vId3 });
  }

  sort(node.begin(), node.end(), compare);

  for(int i=0;i<q;i++){
    //cout << "Enter details of query " << i+1 << endl;
    cin >> query[i].first >> query[i].second;
  }
  
  vector<Dnode> vecID(maxx);
  //initialize vector with vId1
  for(int i=1;i<=m;i++){
    vecID[0].vec.push_back(i);
  }


//for processing node calculations
  for(int i=0;i<n;i++){
    if(node[i].name=="S"){
      int a=0;
      vector<int> v1=vecID[node[i].vId1-1].vec;
      vector<int> v2=vecID[node[i].vId2-1].vec;
      vector<int> v3=vecID[node[i].vId3-1].vec;

      //splitting the input vector
      while (a<v1.size()){
        if(a<v1.size()) v2.push_back(v1[a++]);
        if(a<v1.size()) v3.push_back(v1[a++]);
      }
      vecID[node[i].vId2-1].vec=v2;
      vecID[node[i].vId3-1].vec=v3;
    }
    
    else{
      vector<int> v1=vecID[node[i].vId1-1].vec;
      vector<int> v2=vecID[node[i].vId2-1].vec;
      vector<int> v3=vecID[node[i].vId3-1].vec;
       int ind1=0;
       int ind2=0;
       while(ind1<v1.size() && ind2<v2.size()){
         v3.push_back(v1[ind1++]);
         v3.push_back(v2[ind2++]);
       }
       while(ind1<v1.size()){
         v3.push_back(v1[ind1++]);
       }
       while(ind2<v2.size()){
         v3.push_back(v2[ind2++]);
       }
        
      vecID[node[i].vId3-1].vec=v3;
    }
  }
//for processing query
  cout << endl;
  cout << "Output" << endl;
  for(int i=0;i<q;i++){
        int id = query[i].first - 1;
        int pos = query[i].second - 1;
         if (id < maxx && pos < vecID[id].vec.size()) {
            cout << vecID[id].vec[pos] << endl;
        } else {
            cout << "none" << endl;
        }
  }
  return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3632kb

input:

5 8 26
M 8 9 13
S 2 4 5
S 1 2 3
M 6 5 8
S 4 9 10
S 10 14 15
S 3 6 7
S 7 11 12
2 3
2 4
3 2
3 3
4 2
4 3
5 1
5 2
6 1
6 2
7 1
7 2
8 2
8 3
9 1
9 2
10 1
10 2
11 1
11 2
12 1
13 3
13 4
14 1
14 2
15 1

output:

Enter values of m, n and q: 

Output
5
none
4
none
5
none
3
none
2
none
4
none
3
none
1
none
5
none
4
none
none
3
none
5
none
none

result:

wrong answer 1st lines differ - expected: '5', found: 'Enter values of m, n and q: '