社区讨论
【玄关】【马蜂良好】【变量名意义明确】第一个测试点过不去,其他 AC 求助
P10788[NOI2024] 分数参与者 2已保存回复 7
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 7 条
- 当前快照
- 1 份
- 快照标识符
- @lytdlrw1
- 此快照首次捕获于
- 2024/07/20 08:13 2 年前
- 此快照最后确认于
- 2024/07/20 09:32 2 年前
rt
CPP#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 1e5+5;
struct Table{
int x, y;
string table[200][20];
map<string, int> TableNameToColumn;
map<int, string> ColumnToTableName;
} Tables[100];
int n, q;
map<string, int> TableNameToInt;
map<int, string> IntToTableName;
signed main() {
cin >> n;
for(int i = 1; i <= n; i++) {
string TableName;
cin >> TableName;
IntToTableName[i] = TableName;
TableNameToInt[TableName] = i;
cin >> Tables[i].x >> Tables[i].y;
for(int j = 1; j <= Tables[i].y; j++) {
string ColumnName; cin >> ColumnName;
Tables[i].TableNameToColumn[ColumnName] = j;
Tables[i].ColumnToTableName[j] = ColumnName;
}
for(int j = 1; j < Tables[i].x; j++) {
for(int k = 1; k <= Tables[i].y; k++) {
cin >> Tables[i].table[j][k];
}
}
}
cin >> q;
while(q--) {
string InfoReq, ReqTable, ReqPos;
string ReqHead, Condition;
bool EqualSignMet = false;
cin >> InfoReq >> InfoReq;
cin >> ReqTable >> ReqTable;
cin >> ReqPos >> ReqPos;
map<string, bool> InfoR;
string tmp;
for(int i = 0; i < InfoReq.size(); i++) {
if(InfoReq[i] == ',') {
InfoR[tmp] = true;
tmp = "";
} else {
tmp = tmp + InfoReq[i];
}
} InfoR[tmp] = true;
//cout << tmp << tmp.size() << endl;
for(int i = 0; i < ReqPos.size(); i++) {
if(ReqPos[i] == '=') EqualSignMet = true;
else if(EqualSignMet == false) ReqHead = ReqHead + ReqPos[i];
else if(EqualSignMet == true) Condition = Condition + ReqPos[i];
}
int ReqCol = Tables[TableNameToInt[ReqTable]].TableNameToColumn[ReqHead];
for(int i = 1; i < Tables[TableNameToInt[ReqTable]].x; i++) {
//cout << TableTmp.table[i][ReqCol] << ' ';
//cout << Condition << ' ';
if(Tables[TableNameToInt[ReqTable]].table[i][ReqCol] == Condition) {
// cout << 'd' << " " << endl;
for(int j = 1; j <= Tables[TableNameToInt[ReqTable]].y; j++) {
string TmpHead = Tables[TableNameToInt[ReqTable]].ColumnToTableName[j];
// cout << TmpHead << endl;
if(InfoR[TmpHead] == true) {
cout << Tables[TableNameToInt[ReqTable]].table[i][j] << " ";
}
} cout << endl;
}
}
}
return 0;
}
回复
共 7 条回复,欢迎继续交流。
正在加载回复...