1023 - n = stud[i].college[t]; if(school[n].region ==...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> #include<set> #include<vector> #include<queue> #include<deque> using namespace std; struct Student { int region; double score; int school; int volnum; vector<int> college; }; Student stud[154]; struct Node { int index; int volnum; double score; }; struct University{ struct MyComp{ return a.score < b.score; } }; int region; int num; priority_queue<Node, vector<Node>, MyComp > q; }; University school[52]; queue<int> reg; int studnum,schnum; int main(){ int tstcase; cin>>tstcase; while(tstcase --){ cin>>studnum>>schnum; int i,n,t; for(i=0;i<studnum;i++){ cin>>stud[i].region>>stud[i].score>>n; stud[i].school = -1; stud[i].volnum = -1; stud[i].college.clear(); while(n--){ cin>>t; t--; stud[i].college.push_back(t); } } for(i=0;i<schnum;i++){ cin>>school[i].region>>school[i].num; while(!school[i].q.empty()){ school[i].q.pop(); }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
} Node one; for(i=0;i<studnum;i++){ one.index = i; for(t=0; t<stud[i].college.size();t++){
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n = stud[i].college[t]; if(school[n].region == stud[i].region){ one.score = stud[i].score *10.0/7.0; } else { one.score = stud[i].score; } one.volnum = t; school[n].q.push(one); } } for(i=0;i&lt;schnum;i++){ if(! school[i].q.empty()) reg.push(i); } int pred,v; University *u; while(!reg.empty()){ n = reg.front(); reg.pop(); u = &amp;school[n]; while(u-&gt;num &amp;&amp; !u-&gt;q.empty()){ t = u-&gt;q.top().index; v = u-&gt;q.top().volnum; u-&gt;q.pop(); if(stud[t].school==-1){ stud[t].school = n; stud[t].volnum = v; u-&gt;num --; } else if(stud[t].volnum &gt; v){ pred = stud[t].school; stud[t].school = n; stud[t].volnum = v; if(school[pred].num ++ == 0){ reg.push(pred); } u-&gt;num --; } } } for(i=0;i&lt;studnum;i++){ n = stud[i].school; if(n == -1){ cout&lt;&lt;&quot;not accepted\n&quot;; } else { cout&lt;&lt;(n+1)&lt;&lt;&quot;\n&quot;; } } if(tstcase) cout&lt;&lt;endl; } return 0; }...
View Full Document

Page1 / 3

1023 - n = stud[i].college[t]; if(school[n].region ==...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online