当前位置:网站首页>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;
}
边栏推荐
- Visio draws Tai Chi
- MySQL learning record 13 database connection pool, pooling technology, DBCP, c3p0
- [tomato assistant installation]
- POI add border
- SharedPreferences 源码分析
- Practical development of member management applet 06 introduction to life cycle function and user-defined method
- 关于进程、线程、协程、同步、异步、阻塞、非阻塞、并发、并行、串行的理解
- 深入浅出node模板解析错误escape is not a function
- Understanding of processes, threads, coroutines, synchronization, asynchrony, blocking, non blocking, concurrency, parallelism, and serialization
- After learning classes and objects, I wrote a date class
猜你喜欢
About some basic DP -- those things about coins (the basic introduction of DP)
Coreldraw2022 new version new function introduction cdr2022
CADD课程学习(8)-- 化合物库虚拟筛选(Virtual Screening)
Lombok原理和同时使⽤@Data和@Builder 的坑
Execution order of scripts bound to game objects
Data processing methods - smote series and adasyn
10 exemples les plus courants de gestion du trafic istio, que savez - vous?
Overturn your cognition? The nature of get and post requests
Is the mode of education together - on campus + off campus reliable
Practical development of member management applet 06 introduction to life cycle function and user-defined method
随机推荐
How does computer nail adjust sound
Implementation of knowledge consolidation source code 2: TCP server receives and processes half packets and sticky packets
MIT CMS. 300 session 8 – immersion / immersion
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
QML和QWidget混合开发(初探)
C. The Third Problem(找规律)
Basic explanation of turtle module - draw curve
Mixed development of QML and QWidget (preliminary exploration)
The most detailed and comprehensive update content and all functions of guitar pro 8.0
【HBZ分享】ArrayList的增删慢查询快的原因
Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
2/11 matrix fast power +dp+ bisection
cdc 能全量拉去oracle 表嘛
JVM garbage collector concept
About some basic DP -- those things about coins (the basic introduction of DP)
How does vs change the project type?
[Chongqing Guangdong education] engineering fluid mechanics reference materials of southwestjiaotonguniversity
2/13 review Backpack + monotonic queue variant
【Try to Hack】john哈希破解工具
10個 Istio 流量管理 最常用的例子,你知道幾個?