QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#656934 | #5110. Splitstream | iambotx11 | WA | 1ms | 3552kb | C++14 | 2.3kb | 2024-10-19 13:52:58 | 2024-10-19 13:53:02 |
Judging History
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;
};
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 });
}
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: 3552kb
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: Enter details of Node 1 Enter details of Node 2 Enter details of Node 3 Enter details of Node 4 Enter details of Node 5 Enter details of Node 6 Enter details of Node 7 Enter details of Node 8 Enter details of query 1 Enter details of query 2 Enter details of query 3 Ente...
result:
wrong answer 1st lines differ - expected: '5', found: 'Enter values of m, n and q: '