竹園論壇

標題: 2830 - 蓬莱山辉夜 [打印本頁]

作者: ForTest    時間: 2014-4-30 14:33
標題: 2830 - 蓬莱山辉夜
本帖最後由 ForTest 於 2014-5-3 22:04 編輯

題目:http://www.wikioi.com/problem/2830/
AC Code:http://ideone.com/6xvJIk

最近找到的匪區Judge 有大量NOI題目
這題題意頗詭異 不過直接看題解表示
以时间为关键字将每个用户压入堆
每次输出最先被访问到的用户,
并把时间加上他的时间间隔再重新压入堆。

同時 這個Code有點醜...
前五個貼自己Code的有$$
(如果不是AC Code 樓主/管理員(?)刪回復)

AC證明:http://www.wikioi.com/user/12325/
不過這個網站沒有登入是看不到的...
#include <iostream>
  • #include <cstdio>
  • #include <vector>
  • #include <algorithm>
  • #include <cstring>
  • #include <map>
  • #include <queue>
  • #include <sstream>
  • #include <functional>

  • using namespace std;

  • #define F(a,b) for(int a=0;a<b;++a)
  • typedef long long LL;

  • typedef pair<int,int>P;
  • int main(){
  •         string s;
  •         stringstream ss;
  •         priority_queue<P,vector<P>,greater<P> >p;
  •         map<int,int> m;
  •         while(getline(cin,s)){
  •                 ss << s;
  •                 string a; ss >> a;
  •                 if(a == "#") break;
  •                 int b,c; ss >> b >> c;
  •                 m[b] = c;
  •                 p.push(P(c,b));
  •                 ss.clear();
  •         }
  •         int t; cin >> t;
  •         while(t--){
  •                 P now = p.top(); p.pop();
  •                 cout << now.second << "\n";
  •                 p.push(P(m[now.second] + now.first,now.second));
  •         }
  • }










  • 歡迎光臨 竹園論壇 (http://forum.tfcis.org/) Powered by Discuz! X3.2