Submission #728993

#TimeUsernameProblemLanguageResultExecution timeMemory
728993Jean7Inside information (BOI21_servers)C++14
5 / 100
1875 ms32284 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define pob pop_back #define pub push_back #define lb lower_bound #define ub upper_bound #define low (i&(-i)) #define le (node<<1) #define ri (node<<11) #define mid ((l+r)>>1) #define no void(cout<<"NO\n") #define zer void(cout<<"0\n") #define one void(cout<<"-1\n") #define yes void(cout<<"YES\n") #define sz(x) (int)x.size() #define all(x) x.begin(),x.end() #define mm(x,y) memset(x,y,sizeof(x)) using namespace std ; const int L = 23 ; const int B = 750 ; const int T = 1e3+3 ; const int N = 1e6+6 ; const int M = 1e9+7 ; const int D = 998244353 ; const long long O = 4557430888798830399 ; int n , k ; bool cnt[4003][4003] ; inline void solve () { cin >> n >> k ; for ( int i = 1 ; i <= n ; i++ ) { cnt[i][i] = 1 ; } for ( int i = 1 ; i <= n + k - 1 ; i++ ) { char c ; int x , y ; cin >> c ; if ( c == 'S' ) { cin >> x >> y ; for ( int i = 1 ; i <= n ; i++ ) { if ( cnt[x][i] || cnt[y][i] ) { cnt[x][i] = cnt[y][i] = 1 ; } } } else if ( c == 'Q' ) { cin >> x >> y ; cout << ( cnt[x][y] ? "yes\n" : "no\n" ) ; } else { cin >> x ; int ans = 0 ; for ( int i = 1 ; i <= n ; i++ ) { ans += cnt[i][x] ; } cout << ans << "\n" ; } } } signed main () { //freopen ( ".in" , "r" , stdin ) ; //freopen ( ".out" , "w" , stdout ) ; cin.tie(0) ; cout.tie(0) ; ios_base::sync_with_stdio(0) ; //cout << setprecision(14) << fixed ; int tc = 1 ; //cin >> tc ; while ( tc-- ) { solve() ; } return 0 ; } /// JJJJJJJ EEEEEEE AAAAA NN NN 7777777 /// JJ EE AA AA NNN NN 77 /// JJ EEEEEE AAAAAAA NN N NN 77 /// JJ JJ EE AA AA NN NNN 77 /// JJJJJ EEEEEEE AA AA NN NN 77
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...