답안 #568049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
568049 2022-05-24T14:34:05 Z LittleCube 조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2) C++14
0 / 100
0 ms 340 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;
 
int N, M, adj[2005][2005];
vector<pii> v;
 
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> N >> M;
	
	for(int i = 1; i <= M; i++)
	{
		int A, B;
		cin >> A >> B;
		adj[A][B] = 1;
		v.emplace_back(pii(A, B));
		for(int j = 0; j < N * N; j++)
		{
			if(j >= v.size())
				break;
			auto [x, y] = v[j];
			for(int z = 1; z <= N; z++)
				if(adj[y][z] && adj[z][y] && x != z && adj[x][z] == 0)
				{	
					adj[x][z] = 1;
					v.emplace_back(pii(x, z));
				}
			
			for(int z = 1; z <= N; z++)
				if(adj[y][x] && (adj[z][x] ^ adj[z][y]))
				{
					if(adj[z][x]) 
					{	
						adj[z][y] = 1;
						v.emplace_back(pii(z, y));
					}
					else
					{
						adj[z][x] = 1;
						v.emplace_back(pii(z, x));
					}
				}	
		}
		for(int x = 1; x <= N; x++)
			for(int y = 1; y <= N; y++)
				if(adj[x][y])
					for(int z = 1; z <= N; z++)
						if(adj[y][z] && adj[z][y] && x != z && adj[x][z] == 0)
							assert(false);
		cout << v.size() << '\n';
	}
}

Compilation message

joitter2.cpp: In function 'int main()':
joitter2.cpp:26:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |    if(j >= v.size())
      |       ~~^~~~~~~~~~~
joitter2.cpp:28:9: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   28 |    auto [x, y] = v[j];
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -