CSPS T3
  • 板块学术版
  • 楼主吴思诚
  • 当前回复15
  • 已保存回复17
  • 发布时间2023/10/22 20:14
  • 上次更新2023/11/2 11:48:53
查看原帖
CSPS T3
371848
吴思诚楼主2023/10/22 20:14

我爆零了,赛后写了一个5分的,只针对第一个点,然而WA了。 有没有巨佬帮忙看看。

#include<iostream>
#include<unordered_map>
using namespace std;
typedef long long ll;

namespace AD{
	const int N=810,M=110;
	int top[N],mem,name,vtop[M];
	unordered_map<string,int>name_to_id;
	void sol(){
		int n;
		cin>>n;
		while(n--){
			int op;
			cin>>op;
			if(op==2){
				string t,n;
				cin>>t>>n;
				name_to_id[n]=++name;
				int bk=mem;
				vtop[name]=bk;
				for(int i=0;i<8;++i)top[mem++]=bk;
			}
			else if(op==3){
				string s;
				cin>>s;
				cout<<vtop[name_to_id[s]]<<'\n';
			}
			else{
				ll addr;
				cin>>addr;
				if(addr>=mem)cout<<"ERR\n";
				else cout<<top[addr]<<'\n';
			}
		}
	}
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	using namespace AD;
	sol();
	return 0;
}
2023/10/22 20:14
加载中...