当前位置:网站首页>Uva1592 Database
Uva1592 Database
2022-07-06 04:33:00 【Pecksniff. k】
The original title is :
Ideas : Use one IDcache To assign all strings ID, recycling pair Form a binary . Maintain left endpoint c1, Enumerate right endpoints c2, At the same time through row Scan the assigned from top to bottom id library . Query the first row That's ok pair(c1,c2) Whether it exists or not .
Code :
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<set>// aggregate
#include<map>// mapping
#include<vector>// vector
#include<utility>//pair
#define DEBUG
using namespace std;
map<string,int> IDcache;// Record ID
map<pair<int,int>,int> Binary_pair;// Record where the binary is row
int cnt=0;
int ID(string s)// Distribute ID
{
if(IDcache.count(s))
{
return IDcache[s];
}
else
{
return IDcache[s]=cnt++;
}
}
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,m;
while(cin>>n>>m)
{
IDcache.clear();
Binary_pair.clear();
vector<vector<int>> dict(n,vector<int>(m));// Deposit ID
string s;
cnt=0;
cin.get();// Eliminate line breaks
for(int i=0;i<n;i++)
{
getline(cin,s);
for(int j=0;j<s.length();j++)
{
if(s[j]==',')
{
s[j]=' ';// Replace commas with spaces
}
else if(s[j]==' ')
{
s[j]=',';// Replace the space with an impossible comma
}
}
stringstream ss(s);// Character stream
for(int j=0;j<m;j++)
{
string cur;
ss>>cur;
dict[i][j]=ID(cur);
}
}
#ifndef DEBUG// Debug statement
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cout<<dict[i][j]<<" ";
}
cout<<endl;
}
#endif
if(m>1)
{
for(int c1=0;c1<m-1;c1++)// Maintain left endpoint
{
for(int c2=c1+1;c2<m;c2++)// Enumerate right endpoints
{
Binary_pair.clear();
for(int row=0;row<n;row++)// Traverse from top to bottom
{
pair<int,int> temp(dict[row][c1],dict[row][c2]);
if(Binary_pair.count(temp))// Is not Peter normal form
{
cout<<"NO"<<endl;
cout<<Binary_pair[temp]+1<<" "<<row+1<<endl;
cout<<c1+1<<" "<<c2+1<<endl;
goto out;// Jump out of multiple loops
}
else
{
Binary_pair[temp]=row;
}
}
}
}
}
cout<<"YES"<<endl;
out:;
}
return 0;
}
边栏推荐
- P2022 interesting numbers (binary & digit DP)
- 2327. Number of people who know secrets (recursive)
- Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)
- Can Flink SQL read multiple topics at the same time. How to write in with
- 2/13 qaq~~ greed + binary prefix sum + number theory (find the greatest common factor of multiple numbers)
- CADD课程学习(7)-- 模拟靶点和小分子相互作用 (柔性对接 AutoDock)
- Lombok原理和同时使⽤@Data和@Builder 的坑
- Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
- Lagrange polynomial
- 题解:《单词覆盖还原》、《最长连号》、《小玉买文具》、《小玉家的电费》
猜你喜欢
10個 Istio 流量管理 最常用的例子,你知道幾個?
Stable Huawei micro certification, stable Huawei cloud database service practice
Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
VNCTF2022 WriteUp
Overturn your cognition? The nature of get and post requests
How do programmers teach their bosses to do things in one sentence? "I'm off duty first. You have to work harder."
Query the number and size of records in each table in MySQL database
Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
电脑钉钉怎么调整声音
1291_ Add timestamp function in xshell log
随机推荐
Microservice resource address
cdc 能全量拉去oracle 表嘛
[Chongqing Guangdong education] Suzhou University English film and Television Appreciation reference materials
深入浅出node模板解析错误escape is not a function
Complete list of common functions of turtle module
Easyrecovery靠谱不收费的数据恢复电脑软件
About some basic DP -- those things about coins (the basic introduction of DP)
CADD course learning (8) -- virtual screening of Compound Library
解决“C2001:常量中有换行符“编译问题
Fedora/REHL 安装 semanage
How to solve the problem of slow downloading from foreign NPM official servers—— Teach you two ways to switch to Taobao NPM image server
VNCTF2022 WriteUp
How to estimate the population with samples? (mean, variance, standard deviation)
When debugging after pycharm remote server is connected, trying to add breakpoint to file that does not exist: /data appears_ sda/d:/segmentation
Fedora/rehl installation semanage
2328. 网格图中递增路径的数目(记忆化搜索)
SharedPreferences 源码分析
我想问一下 按照现在mysql-cdc的设计,全量阶段,如果某一个chunk的binlog回填阶段,
满足多元需求:捷码打造3大一站式开发套餐,助力高效开发
Solution of storage bar code management system in food industry