제출 #624033

#제출 시각아이디문제언어결과실행 시간메모리
624033radal조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2)C++17
1 / 100
9 ms468 KiB
#include <bits/stdc++.h> #pragma GCC target("sse,sse2,avx2") #pragma GCC optimize("unroll-loops,O2") #define rep(i,l,r) for (int i = l; i < r; i++) #define repr(i,r,l) for (int i = r; i >= l; i--) #define X first #define Y second #define all(x) (x).begin() , (x).end() #define pb push_back #define endl '\n' #define debug(x) cerr << #x << " : " << x << endl; using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pll; constexpr int N = 50+10,mod = 998244353,inf = 1e9+10,sq = 700; inline int mkay(int a,int b){ if (a+b >= mod) return a+b-mod; if (a+b < 0) return a+b+mod; return a+b; } inline int poww(int a,int k){ if (k < 0) return 0; int z = 1; while (k){ if (k&1) z = 1ll*z*a%mod; a = 1ll*a*a%mod; k /= 2; } return z; } int a[N][N]; int main(){ ios :: sync_with_stdio(0); cin.tie(0); int n,m; cin >> n >> m; ll ans = 0; while (m--){ int u,v; cin >> u >> v; if (a[u][v] == 1){ cout << ans << endl; continue; } a[u][v] = 1; bool f = 1; ans++; while (f){ f = 0; rep(x,1,n+1){ rep(y,1,n+1){ if (!a[x][y] || !a[y][x]) continue; rep(z,1,n+1){ if (z == y || a[z][y] || !a[z][x]) continue; a[z][y] = 1; f = 1; ans++; } } } } cout << ans << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...