记录编号 | 235007 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | [SDOI 2012 DAY2]集合 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 2.028 s | ||
提交时间 | 2016-03-10 09:15:59 | 内存使用 | 10.23 MiB | ||
#include<cstdio> #include<iostream> #include<string> #include<algorithm> using namespace std; const int SIZEM=500010,SIZEN=100010; class miku { public: int fr,to,w; int coA,coB; miku(){} miku(int a,int b,int c,int d,int e) { fr=a,to=b,w=c; } }E[SIZEM]; int co[SIZEN]; bool cmp(miku a,miku b){ return a.w<b.w;} int N,M; void read() { scanf("%d%d",&N,&M); int fr,to,w; for(int i=1;i<=M;i++) { scanf("%d%d%d",&fr,&to,&w); E[i]=miku(fr,to,w,1,1); co[fr]=co[to]=1; } sort(E+1,E+M+1,cmp); } void get(int a,int b) { for(int i=1;i<=M;i++) if((co[E[i].fr]==a&&co[E[i].to]==b)||(co[E[i].fr]==b&&co[E[i].to]==a)) { printf("%d\n",E[i].w); return; } printf("No Found!\n"); } void move(int x,int y) { co[y]=x; } void work() { int k; scanf("%d",&k); string str; int x; for(int i=1;i<=k;i++) { cin>>str; if(str[0]=='A') { int a=str[3]-'A'+1,b=str[4]-'A'+1; get(a,b); } else { scanf("%d",&x); int a=str[4]-'A'+1; move(a,x); } } } int main() { freopen("seta.in","r",stdin); freopen("seta.out","w",stdout); read(); work(); return 0; }