Submission #846180

# Submission time Handle Problem Language Result Execution time Memory
846180 2023-09-07T12:11:56 Z vjudge1 KOVANICE (COI15_kovanice) C++11
0 / 100
107 ms 8672 KB
#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)] = ata[atabul(e1)];
		}
		else if (ans[atabul(e2)]!=0){
			ata[atabul(e1)] = ata[atabul(e2)];
		}
		else{
			ata[atabul(e1)] = ata[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();
    }
}



Compilation message

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
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 3172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 107 ms 8672 KB Output isn't correct
2 Halted 0 ms 0 KB -