当前位置:网站首页>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;
}边栏推荐
- Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
- Overturn your cognition? The nature of get and post requests
- C. The Third Problem(找规律)
- MIT CMS. 300 session 8 – immersion / immersion
- Stable Huawei micro certification, stable Huawei cloud database service practice
- P2102 floor tile laying (DFS & greed)
- PTA tiantisai l1-078 teacher Ji's return (15 points) detailed explanation
- 2327. Number of people who know secrets (recursive)
- English Vocabulary - life scene memory method
- 拉格朗日插值法
猜你喜欢

题解:《单词覆盖还原》、《最长连号》、《小玉买文具》、《小玉家的电费》

Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022

Selection of slow motion function

Fedora/rehl installation semanage

canal同步mysql数据变化到kafka(centos部署)

Guitar Pro 8.0最详细全面的更新内容及全部功能介绍

VNCTF2022 WriteUp

One question per day (Mathematics)

Practical development of member management applet 06 introduction to life cycle function and user-defined method

Dry goods collection | Vulkan game engine video tutorial
随机推荐
P2102 floor tile laying (DFS & greed)
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
C. The third problem
Query the number and size of records in each table in MySQL database
Deep learning framework installation (tensorflow & pytorch & paddlepaddle)
npm命令--安装依赖包--用法/详解
[Chongqing Guangdong education] engineering fluid mechanics reference materials of southwestjiaotonguniversity
CADD课程学习(8)-- 化合物库虚拟筛选(Virtual Screening)
满足多元需求:捷码打造3大一站式开发套餐,助力高效开发
VNCTF2022 WriteUp
VPP performance test
How to estimate the population with samples? (mean, variance, standard deviation)
VPP性能测试
Visio draw fan
1291_Xshell日志中增加时间戳的功能
Coreldraw2022 new version new function introduction cdr2022
BOM - location, history, pop-up box, timing
IDEA编译JSP页面生成的class文件路径
Easyrecovery靠谱不收费的数据恢复电脑软件
颠覆你的认知?get和post请求的本质