zoukankan
html css js c++ java
HDU2254 奥运 矩阵应用
//最原始的矩阵应用,不解释 #include "Mat.h" #include <iostream> #include<map> #include<string> using namespace std; map<string, int> M; Mat mat, temp1, temp2; int main() { int n, cnt, k, t1, t2, ans, a1, a2; string p1, p2, v1, v2; mod = 2008; while(cin>>n) { mat.clear(); M.clear(); cnt = 1; while(n--) { cin>>p1>>p2; if(M[p1] == 0) M[p1] = cnt++; if(M[p2] == 0) M[p2] = cnt++; mat.s[M[p1]][M[p2]]++; } mat.sizei = cnt; mat.sizej = cnt; cin>>k; while(k--) { cin>>v1>>v2>>t1>>t2; if(M[v1]==0||M[v2]==0||(t1==0&&t2==0)) { cout<<0<<endl; continue; } if(t1>t2) swap(t1, t2); temp1 = mat;temp2 = mat; temp1.solve(t2);a1 = temp1.s[M[v1]][M[v2]]; if(t1 <= 1) a2 = 0; else { temp2.solve(t1-1); a2 = temp2.s[M[v1]][M[v2]]; } ans = (a1 - a2 + mod ) % mod; cout<<ans<<endl; } } return 0; }
查看全文
相关阅读:
day12. 闭包
day11.函数的全局变量和局部变量
day10.函数基础及函数参数
day9.关于文件的操作
day7.关于字符串的相关操作
day8.列表、字典、集合相关操作
day6. while双项循环及for循环
LeetCode-Unique Binary Search Trees II
LeetCode-Unique Binary Search Trees
LeetCode-Edit Distance
原文地址:https://www.cnblogs.com/windmissing/p/2559895.html
最新文章
CF1517E
ARC114
ARC114
ARC114
联合省选2021爆零记
Codeforces1508D
Codeforces1508D
UVA1389 Hard Life (01分数规划+最大流)
rkk的CSP2019白给记
bzoj2007/luoguP2046 海拔(平面图最小割转对偶图最短路)
热门文章
hdu5197 DZY Loves Orzing(FFT+分治)
hdu5322 Hope(dp+FFT+分治)
(bzoj4408)[FJOI2016]神秘数(可持久化线段树)
bzoj2989 数列(KDTree)
01-k8s 架构
configparser 模块
深刻理解Python中的元类(metaclass)
使用@property
Django 基础
day13. 迭代器与高阶函数
Copyright © 2011-2022 走看看