답안 #71968

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71968 2018-08-26T04:19:29 Z 이시대의진정한갓겜스타투(#2216, kjp4155) 마법 다우징 (FXCUP3_magic) C++17
0 / 100
2 ms 376 KB
#include "dowsing.h"
#include<bits/stdc++.h>
using namespace std;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()
#define geti1(X) cin >> X
#define geti2(X,Y) cin >> X >> Y
#define geti3(X,Y,Z) cin >> X >> Y >> Z
#define geti4(X,Y,Z,W) cin >> X >> Y >> Z >> W
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

void FindTreasure(int N) {
	vector<int> RS,CS;
	repp(i,N) RS.push_back(i);
	repp(i,N) CS.push_back(i);
	srand(412421);
	int CNT = 150;
	while( sz(RS) + sz(CS) > CNT ){
		int r1 = rand() % sz(RS);
		int r2 = rand() % sz(CS);

		int x = RS[r1], y = CS[r2];
		int res = Detect(x,y);
		CNT--;
	
		if( res == 1 ) continue;
		
		RS.erase(RS.begin()+r1);
		CS.erase(CS.begin()+r2);
	}
	int R,C;
	map<int,int> rm, cm;
	for(int i=0;i<sz(RS);i++){
		int res = Detect(RS[i], CS[0]);	
		rm[RS[i]] += res;
	}
	for(int i=0;i<sz(CS);i++){
		int res = Detect(RS[0], CS[i]);
		cm[CS[i]] += res;
	}

	int mx = -1;
	for(auto e : rm){
		if( mx < e.Se ){
			mx = e.Se; R = e.Fi;
		}
	}
	mx = -1;
	for(auto e : cm){
		if( mx < e.Se ){
			mx = e.Se; C = e.Fi;
		}
	}

	Report(R,C);
}

Compilation message

dowsing.cpp: In function 'void FindTreasure(int)':
dowsing.cpp:61:8: warning: 'C' may be used uninitialized in this function [-Wmaybe-uninitialized]
  Report(R,C);
  ~~~~~~^~~~~
dowsing.cpp:61:8: warning: 'R' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Correct : C = 6
2 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -