#include <bits/stdc++.h>
using namespace std;
const int sz = 3e5 + 5;
vector<int> az[sz],cox[sz],ber[sz];
vector<int> ans(sz,-1);
vector<bool> vis(sz,0);
void dfs(int a,int b){
vis[a] = 1;
ans[a] = b;
for(auto &i : az[a]){
if(!vis[i]){
dfs(i,1);
}
}
for(auto &i : ber[a]){
if(!vis[i]){
dfs(i,b);
}
}
for(auto &i : cox[a]){
if(!vis[i]){
dfs(i,2);
}
}
}
signed main(){
int n,m,k;
cin >> n>> m >> k;
vector<int> iki,bir;
string s;
while(k--){
cin >> s;
int a=0,b=0;
char c='.';
for(int i=0;i<s.size();++i){
if(s[i] >= '0' && s[i] <= '9'){
if(c == '.')a = a * 10 + (s[i] - '0');
else b = b * 10 + (s[i] - '0');
}else{
c = s[i];
}
}
if(c == '='){
ber[a].push_back(b);
ber[b].push_back(a);
}else if(c == '<'){
iki.push_back(b);
bir.push_back(a);
cox[a].push_back(b);
az[b].push_back(a);
}else{
iki.push_back(a);
bir.push_back(b);
cox[b].push_back(a);
az[a].push_back(b);
}
}
for(int _=0;_<5;++_){
for(auto &temp : cox){
for(auto &i : temp){
if(!vis[i])dfs(i,2);
}
}
}
for(int i=1;i<=m;++i){
if(ans[i] == -1){
cout << "?";
}else{
cout << "R" << ans[i];
}
cout << '\n';
}
}
Compilation message
kovanice.cpp: In function 'int main()':
kovanice.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i=0;i<s.size();++i){
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
22864 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
112 ms |
29368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
46 ms |
25300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
313 ms |
48176 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |