Submission #26585385


Source Code Expand

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/













int N, M;
int A[1010];
int B[1010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, M) cin >> B[i];

	vector<int> ans;
	rep(i, 0, N) rep(j, 0, M) if (A[i] == B[j]) ans.push_back(A[i]);
	sort(all(ans));

	rep(i, 0, ans.size()) {
		if (0 < i) printf(" ");
		printf("%d", ans[i]);
	}
	printf("\n");
}





Submission Info

Submission Time
Task B - intersection
User hamayanhamayan
Language C++ (GCC 9.2.1)
Score 8
Code Size 1726 Byte
Status AC
Exec Time 6 ms
Memory 3772 KiB

Compile Error

./Main.cpp: In function ‘void _main()’:
./Main.cpp:2:33: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    2 | #define rep(i,a,b) for(int i=a;i<b;i++)
......
   48 |  rep(i, 0, ans.size()) {
      |      ~~~~~~~~~~~~~~~~            
./Main.cpp:48:2: note: in expansion of macro ‘rep’
   48 |  rep(i, 0, ans.size()) {
      |  ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 8 / 8
Status
AC × 2
AC × 10
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 6 ms 3588 KiB
001.txt AC 2 ms 3556 KiB
002.txt AC 3 ms 3448 KiB
003.txt AC 3 ms 3660 KiB
004.txt AC 3 ms 3580 KiB
005.txt AC 4 ms 3760 KiB
006.txt AC 3 ms 3772 KiB
007.txt AC 5 ms 3764 KiB
example0.txt AC 2 ms 3760 KiB
example1.txt AC 1 ms 3532 KiB