Submission #1019458

# Submission time Handle Problem Language Result Execution time Memory
1019458 2024-07-10T21:24:55 Z stefanopulos Dijamant (COI16_dijament) C++17
27 / 100
2000 ms 11904 KB
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ldb;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ldb,ldb> pdd;

#define ff(i,a,b) for(int i = a; i <= b; i++)
#define fb(i,b,a) for(int i = b; i >= a; i--)
#define trav(a,x) for(auto& a : x)
 
#define sz(a) (int)(a).size()
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// os.order_of_key(k) the number of elements in the os less than k
// *os.find_by_order(k)  print the k-th smallest number in os(0-based)

const int mod = 1000000007;
const int inf = 1e9 + 5;
const int mxN = 2005; 

int n;

int glv[mxN];
vector<int> A[mxN];

bool res[mxN];

vector<int> g[mxN];

bool P[mxN][mxN];

bool visited[mxN];
void dfs(int v, int r){
    visited[v] = 1; P[r][v] = 1;
    for(auto u : g[v]){
        if(!visited[u]){
            dfs(u, r);
        }
    }
}


int main(){
    cin.tie(0)->sync_with_stdio(0);

    cin >> n; 
    string s; getline(cin, s);

    ff(i,1,n)res[i] = 1;

    map<string,int> mp;
    ff(i,1,n){
        getline(cin, s);

        int m = sz(s), last = 0; string ime = "";
        ff(j,0,m - 1){
            if(s[j] != ' ')continue;
            
            ime = s.substr(last, j - last);
            if(mp.count(ime)){
                res[i] = 0;
                break;
            }

            last = j + 1;
            break;
        }

        if(res[i] == 0)continue;

        ff(j,last,m - 1){
            if(s[j] != ' ')continue;
            
            string t = s.substr(last, j - last);
            if(t != ":" && t != ";"){
                if(!mp.count(t)){
                    res[i] = 0;
                    break;
                }

                A[i].pb(mp[t]);
            }

            last = j + 1;
        }

        if(res[i] == 0)continue;
        mp[ime] = i;

    }

    ff(i,1,n){
        if(res[i] == 0)continue;

        for(auto c : A[i])g[i].pb(c);
        
        ff(j,1,n)visited[j] = 0;
        dfs(i, i);

        bool ok = 1;
        ff(a,1,i - 1){
            ff(b,a + 1,i - 1){
                if(!P[i][a] || !P[i][b])continue;

                if(!P[a][b] && !P[b][a]){
                    ff(c,1,n){
                        if(P[a][c] && P[b][c]){
                            ok = 0;
                            break;
                        }
                    }
                }
            }

        }

        if(ok == 0){
            res[i] = 0;
            continue;
        }

        res[i] = 1; 

    }

    ff(i,1,n)cout << (res[i] == 0 ? "greska" : "ok") << '\n';

    return 0;
}
/*



// probati bojenje sahovski
*/
 
 
 
 
 
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 636 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 636 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Incorrect 1 ms 604 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 346 ms 11024 KB Output is correct
2 Correct 393 ms 11904 KB Output is correct
3 Correct 6 ms 4764 KB Output is correct
4 Correct 44 ms 1620 KB Output is correct
5 Correct 80 ms 2136 KB Output is correct
6 Correct 605 ms 2640 KB Output is correct
7 Correct 1487 ms 2896 KB Output is correct
8 Execution timed out 2072 ms 3104 KB Time limit exceeded
9 Halted 0 ms 0 KB -