제출 #846213

#제출 시각아이디문제언어결과실행 시간메모리
846213vjudge1KOVANICE (COI15_kovanice)C++98
50 / 100
2039 ms35440 KiB
#include <bits/stdc++.h> using namespace std; #pragma optimize "DostSeferoğlu" #pragma GCC optimize("unroll-loops,Ofast") #pragma GCC target("avx2,tune=native") #define int long long #define pii pair<int,int> #define bg begin #define vi vector<int> #define endl '\n' #define vvi vector<vi> #define vp vector<pii> #define sp << " " << #define ff first #define ss second #define brake {cout << "OK\n";return;} #define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;} #define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx) #define F(xx,yy) for (int xx=1;xx<=yy;++xx) #define pb push_back const int inf = 1e18; const int MOD = 998244353; const int N = 3e5+1; vi dad(N),edges[N],inc[N],dp(N,-1),done(N,0),type(N,-1); int find(int x) { if (x == dad[x]) return x; return dad[x] = find(dad[x]); } void unite(int x,int y) { dad[find(x)] = find(y); } int dfs(int node) { if (dp[node] != -1) return dp[node]; int ans = 0; for (auto nb : edges[node]) { ans = max(ans,dfs(nb)+1); } return dp[node] = ans; } void yupee(int node,int ty) { type[node] = ty; for (auto nb : edges[node]) { if (dp[nb] == dp[node]-1) { yupee(nb,ty+1); } } } void solve() { int n,m,k; cin >> n >> m >> k; F(i,m) dad[i] = i; dad[0]=0; vp sms; while (k--) { string s; cin >> s; string n1,n2; int seeneq = 0,seensm=0,seenbg=0; for (auto c : s) { if (c == '=') { seeneq = 1; continue; } if (c == '<') { seensm = 1; continue; } if (c == '>') { seenbg = 1; continue; } if (seeneq || seenbg || seensm) { n2+=c; }else n1+=c; } int x = stoi(n1); int y = stoi(n2); if (seeneq) unite(x,y); else if (seensm) sms.pb({x,y}); else sms.pb({y,x}); } for (auto it : sms) { edges[find(it.ff)].pb(find(it.ss)); inc[find(it.ss)].pb(find(it.ff)); } for (int i=1;i<=m;i++) dfs(find(i)); for (int i=1;i<=m;i++) { if (!done[find(i)] && dp[find(i)] == n-1) { yupee(find(i),1); } } for (int i=1;i<=m;i++) { if (type[find(i)]!=-1) { cout << "K" << type[find(i)] << endl; } else { cout << "?\n"; } } } signed main() { ios_base::sync_with_stdio(0);cin.tie(0); #ifdef Local freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t = 1; //cin >> t; while (t --> 0) solve(); }

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

kovanice.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize "DostSeferoğlu"
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...