제출 #1120614

#제출 시각아이디문제언어결과실행 시간메모리
1120614Fikrat_AsadzadehKOVANICE (COI15_kovanice)C++14
0 / 100
189 ms27304 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define FORI(i, n) for(ll i = 0; i < n; i++) #define FOR(i, n) for(ll i = 1; i <= n; i++) typedef vector<ll> vl; typedef set<ll> setl; #define ff first #define ss second #define all(v) v.begin(), v.end() #define pll pair<ll, ll> #define db double #define nll cout << "\n" #define nl "\n" #define sync ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); const ll mod = 1e9 + 7; const int MAX = 300000 + 5; const ll lmax = 9223372036854775807; const int imax = 2147483647; ll n, m, k, res, rnk[MAX]; // ll a[MAX]; class dsu { int n; vector <int> root, sz; int comp; public : dsu(int _n) : n(_n) { root.resize(n); sz.resize(n, 1); iota(root.begin(), root.end(), (int)0); comp = n; } int get_root(int u) { return (u == root[u]? u: (root[u] = get_root(root[u]))); } bool connected(int u, int v) { if (get_root(u) == get_root(v)) return true; return false; } void merge(int u, int v) { if (connected(u, v)) return ; u = get_root(u); v = get_root(v); comp--; if (sz[v] > sz[u]) swap(u, v); root[v] = u; sz[u] += sz[v]; } int components() { return comp; } }; void solve(){ cin >> n >> m >> k; string s; vector < pair < ll, pll > > v; ll a, b; dsu t(MAX + 1); FOR(i, k){ cin >> s; ll ind; string s1, s2; FORI(i, s.size()){ if(!isdigit(s[i])){ ind = i; break; } s1 += (s[i]); } for(ll i = ind + 1; i < s.size(); i++)s2 += (s[i] ); a = stoi(s1); b = stod(s2); cout << a << " " << b << nl; if(s[ind] == '='){ t.merge(a, b); } else if(s[ind] == '>'){ v.push_back({2, {a, b}}); } else{ v.push_back({1, {a, b}}); } } FORI(i, k){ if(v[i].ff){ a = v[i].ss.ff; b = v[i].ss.ss; if(v[i].ff == 1){ rnk[t.get_root(a)] = 1; rnk[t.get_root(b)] = 2; } else if(v[i].ff == 2){ rnk[t.get_root(b)] = 1; rnk[t.get_root(a)] = 2; } } } FOR(i, m){ if(rnk[t.get_root(i)] == 0){ cout << '?'; } else { if(rnk[t.get_root(i)] == 1)cout << "K1"; else cout << "K2"; } nll; } } signed main(){ // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); sync; ll t = 1; // cin >> t; FOR(i, t){ // cout << "Case #" << i << ": "; solve(); } }

컴파일 시 표준 에러 (stderr) 메시지

kovanice.cpp: In function 'void solve()':
kovanice.cpp:5:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define FORI(i, n) for(ll i = 0; i < n; i++)
......
   72 |         FORI(i, s.size()){
      |              ~~~~~~~~~~~            
kovanice.cpp:72:9: note: in expansion of macro 'FORI'
   72 |         FORI(i, s.size()){
      |         ^~~~
kovanice.cpp:79:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |         for(ll i = ind + 1; i < s.size(); i++)s2 += (s[i] );
      |                             ~~^~~~~~~~~~
kovanice.cpp:83:17: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
   83 |         if(s[ind] == '='){
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...