이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define lg(a) (31 - __builtin_clz((a)))
#define endl ("\n")
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define vi vector<int>
#define st first
#define nd second
#define all(aa) aa.begin(), aa.end()
#define rall(aa) aa.rbegin(), aa.rend()
#define until(n, v) (int) (lower_bound(v.begin(), v.end(), n)-v.begin()) //# of elements < n
#define after(n, v) (int) (v.end()-upper_bound(v.begin(), v.end(), n)) //# of elements > n
#define sameas(n, v) (int) (upper_bound(v.begin(), v.end(), n) - lower_bound(v.begin(), v.end(), n)) //# of elements ==n
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;
/*
*/
vector<int> ata;
int atabul(int x){
if(ata[x] == x) return x;
return ata[x] = atabul(ata[x]);
}
void solve(){
int n, m, v; cin >> n >> m >> v;
ata.resize(m+1);
for(int i=1;i<=m;i++){
ata[i] = i;
}
vector<int> ans(m+1, 0);
vector<pair<int, int>> eq;
vector<pair<int, int>> gr; // first = 1; second = 2;
for(int i=0;i<v;i++){
string s; cin >>s;
if(s[1] == '<'){
gr.pb({s[0]- '0', s[2]- '0'});
}
else{
eq.pb({s[0]- '0', s[2]- '0'});
}
}
for(auto [s, l] : gr){
ans[s] = 1;
ans[l] = 2;
}
for(auto [e1, e2] : eq){
if(ans[atabul(e1)]!=0){
ata[atabul(e2)] = atabul(e1);
}
else if (ans[atabul(e2)]!=0){
ata[atabul(e1)] = atabul(e2);
}
else{
ata[atabul(e1)] = atabul(e2);
}
}
for(int i=1;i<=m;i++){
if(ans[atabul(i)]==0){
cout<<'?'<<endl;
}
else{
cout<<'K'<<ans[atabul(i)]<<endl;
}
// cout<<i<<" ATA: " << atabul(i)<<endl;
}
}
int main(){
int test;
// cin >> test;
test =1;
while (test--){
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
kovanice.cpp: In function 'void solve()':
kovanice.cpp:52:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
52 | for(auto [s, l] : gr){
| ^
kovanice.cpp:56:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
56 | for(auto [e1, e2] : eq){
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |