2456: mode

题目链接

题目大意:求众数,内存1M

题解:自行google摩尔排序算法

我的收获:Orz

#include <cstdio>
using namespace std;
int n,now,tot,x; 
int main()
{
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&x);
        if(tot==0)
        now=x,tot++;
        else if(now==x) tot++;
        else tot--;
    }
    printf("%d\n",now);
    return 0;
} 
std::vector<InputTarget> inputTargets; 2380 2381 InputEventInjectionResult injectionResult; 2382 if (isPointerEvent) { 2383 // Pointer event. (eg. touchscreen) 2384 2385 if (mDragState && 2386 (entry->action & AMOTION_EVENT_ACTION_MASK) == AMOTION_EVENT_ACTION_POINTER_DOWN) { 2387 // If drag and drop ongoing and pointer down occur: pilfer drag window pointers 2388 pilferPointersLocked(mDragState->dragWindow->getToken()); 2389 } 2390 2391 Result<std::vector<InputTarget>, InputEventInjectionResult> result = 2392 mTouchStates 2393 .findTouchedWindowTargets(currentTime, *entry, 2394 mDragState ? mDragState->dragWindow : nullptr, 2395 std::bind_front(&InputDispatcher:: 2396 addDragEventLocked, 2397 this), 2398 std::bind_front(&InputDispatcher:: 2399 logDispatchStateLocked, 2400 this)); 2401 2402 if (result.ok()) { 2403 inputTargets = std::move(*result); 2404 //#ifdef OPLUS_FEATURE_MOTION_INTERCEPT 2405 //Haibing.Wang@ANDROID.INPUT, 2025/04/16, Add for fp-quick and filter invalid events 2406 { 2407 if ((entry->edgeFlags == OPLUS_FLAG_INJECT_REPLACE_DEVICE_ID) && mDragState) { 2408 sp<IBinder> token = mDragState->dragWindow->getToken(); 2409 std::erase_if(inputTargets, [&](const InputTarget& inputTarget) { 2410 return token == inputTarget.connection->getToken(); 2411 }); 2412 } 2413 } 2414 //#endif /* OPLUS_FEATURE_MOTION_INTERCEPT */ 2415 injectionResult = InputEventInjectionResult::SUCCEEDED; 2416 } else { 2417 injectionResult = result.error().code(); 2418 } 2419 } else { 2420 // Non touch event. (eg. trackball) 2421 Result<sp<WindowInfoHandle>, InputEventInjectionResult> result = 2422 findFocusedWindowTargetLocked(currentTime, *entry, nextWakeupTime); 2423 if (result.ok()) { 2424 sp<WindowInfoHandle>& focusedWindow = *result; 2425 LOG_ALWAYS_FATAL_IF(focusedWindow == nullptr); 2426 addWindowTargetLocked(focusedWindow, InputTarget::DispatchMode::AS_IS, 2427 InputTarget::Flags::FOREGROUND, getDownTime(*entry), 2428 inputTargets); 2429 injectionResult = InputEventInjectionResult::SUCCEEDED; 2430 } else { 2431 injectionResult = result.error().code(); 2432 } 2433 } 2434 if (injectionResult == InputEventInjectionResult::PENDING) { 2435 return false; 2436 } 2437 2438 #ifdef OPLUS_FEATURE_GESTURE_SCREENSHOT 2439 //ZhouWei@ANDROID.INPUT, 2020/05/30, Add for remove cancel event when begin three pointer shot screen 2440 if (injectionResult == InputEventInjectionResult::FAILED && isPointerEvent && entry->getPointerCount() == THREE_POINTER_NUM) { 2441 injectionResult = InputEventInjectionResult::SUCCEEDED; 2442 } 2443 #endif /* OPLUS_FEATURE_GESTURE_SCREENSHOT */ 2444 2445 setInjectionResult(*entry, injectionResult); 2446 if (injectionResult == InputEventInjectionResult::TARGET_MISMATCH) { 2447 return true; 2448 } 2449 if (injectionResult != InputEventInjectionResult::SUCCEEDED) { 2450 CancelationOptions::Mode mode( 2451 isPointerEvent ? CancelationOptions::Mode::CANCEL_POINTER_EVENTS 2452 : CancelationOptions::Mode::CANCEL_NON_POINTER_EVENTS); 2453 CancelationOptions options(mode, "input event injection failed", entry->traceTracker); 2454 options.displayId = entry->displayId; 2455 synthesizeCancelationEventsForMonitorsLocked(options); 2456 return true; 2457 } 2458 2459 // Add monitor channels from event's or focused display. 2460 addGlobalMonitoringTargetsLocked(inputTargets, getTargetDisplayId(*entry)); 2461 2462 if (mTracer) { 2463 ensureEventTraced(*entry); 2464 for (const auto& target : inputTargets) { 2465 mTracer->dispatchToTargetHint(*entry->traceTracker, target); 2466 } 2467 }
最新发布
10-22
package com.oplus.engineermode.command; import android.app.ActivityManager; import android.app.IActivityManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.RemoteException; import android.os.UserHandle; import com.oplus.engineermode.utils.Log; import com.oplus.engineermode.utils.EngineerEnvironment; import com.oplus.engineermode.utils.ProjectFeatureOptions; import com.oplus.engineermode.impl.SecrecyServiceHelper; import com.oplus.engineermode.utils.SystemProperties; import com.oplus.engineermode.command.PayJoyAccessService; import java.io.File; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Locale; import java.util.Map; public class EngineerModeOrderReceiver extends BroadcastReceiver { private static final String TAG = "CommercialEngineerMode_EngineerModeOrderReceiver"; private static final String ORDER_LIST_IN_SYSTEM = "engineer_order_list.xml"; private static final String ORDER_LIST_IN_SYSTEM_JP = "engineer_order_list_jp.xml"; private static final String ORDER_LIST_IN_DATA = "/data/engineermode/engineer_config_list.xml"; private static final String ORDER_LIST_OVERLAY = "engineer_order_list_overlay.xml"; private static final int USERID_REPAIR = 888; private static final String[] BRANDS = new String[]{"SOFTBANK", "YMOBILE"}; private static final boolean mIsJP = Arrays.asList(BRANDS).contains(SystemProperties.get("ro.oplus.pipeline.carrier", "")); private static Map<String, EngineerModeOrderItem> sOrderMap = null; private static boolean sIsAppEncrypt; private EngineerModeOrderHandler mHandler; @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "engineermode receiver:" + intent); int current = 0; try { final IActivityManager activityManager = ActivityManager.getService(); if (activityManager != null) { current = activityManager.getCurrentUserId(); } } catch (RemoteException e) { Log.e(TAG, "get current user id failed, e = " + e.getMessage()); } Log.d(TAG, "onReceive uid:" + current); if (!UserHandle.of(current).isSystem() && (current != USERID_REPAIR)) { Log.i(TAG, "Not in Master User, just return."); return; } if (intent == null || intent.getAction() == null) { Log.e(TAG, "intent invalid"); return; } String order = null; try { order = intent.getStringExtra("order"); } catch (Exception e) { order = null; } if (order == null) { Log.e(TAG, "order invalid"); return; } if (order.equals("*#9434#") && PayJoyAccessService.shouldRunPayJoyAccessService(context)) { return; } if (order.equals("*#0000#") && ProjectFeatureOptions.IS_EXP_VERSION) { return; } else if (order.equals("*#456225#")) { return; } boolean isEncrypt = SecrecyServiceHelper.isSecrecySupported() && SecrecyServiceHelper.getSecrecyState(SecrecyServiceHelper.APP_TYPE); Log.i(TAG, "isEncrypt = " + isEncrypt); if ((sOrderMap == null) || sOrderMap.isEmpty() || (sIsAppEncrypt != isEncrypt)) { //save encrypt state for update order list after decrypt sIsAppEncrypt = isEncrypt; if (new File(ORDER_LIST_IN_DATA).exists()) { Log.i(TAG, "read file " + ORDER_LIST_IN_DATA); Map<String, EngineerModeOrderItem> sysOrderMap = new HashMap<>(); Map<String, EngineerModeOrderItem> dataOrderMap = new HashMap<>(); int sysVersion = parseOrderList(context, sysOrderMap, isEncrypt, false); int dataVersion = parseOrderList(context, dataOrderMap, isEncrypt, true); Log.i(TAG, String.format(Locale.US, "sys:%d, data:%d", sysVersion, dataVersion)); if (sysVersion > dataVersion) { sOrderMap = sysOrderMap; } else { sOrderMap = dataOrderMap; } } else { if (sOrderMap == null) { sOrderMap = new HashMap<>(); } int sysVersion = parseOrderList(context, sOrderMap, isEncrypt, false); Log.i(TAG, "sys:" + sysVersion); } } if (mHandler == null) { mHandler = new EngineerModeOrderHandler(context); } //将默认支持的指令在这里做隔离 if (sOrderMap.containsKey(order)) { EngineerModeOrderItem item = sOrderMap.get(order); Log.i(TAG, "item=" + ((item != null) ? item.toString() : "")); mHandler.handleEngineerModeOrder(item); } else { Log.i(TAG, "orderMap doesn't have order:" + order); } } private int parseOrderList(Context context, Map<String,EngineerModeOrderItem> map, Boolean isEncrypt, Boolean isData) { int version = 0; if (map == null) { map = new HashMap<>(); } if (isData) { File file = new File(ORDER_LIST_IN_DATA); Log.i(TAG, "isData"); version = EngineerModeOrderParser.parseOrderList(context, file, map, isEncrypt); } else { Log.i(TAG, "isData not"); version = EngineerModeOrderParser.parseOrderList(context, new File(EngineerEnvironment.getSystemExtEngineerConfigRootDir(), (mIsJP ? ORDER_LIST_IN_SYSTEM_JP : ORDER_LIST_IN_SYSTEM)), map, isEncrypt); File file = new File(EngineerEnvironment.getBigBallEngineerConfigRootDir(), ORDER_LIST_OVERLAY); if (!file.exists()) { file = new File(EngineerEnvironment.getMyCarrierEngineerConfigRootDir(), ORDER_LIST_OVERLAY); } if (file.exists()) { Map<String, EngineerModeOrderItem> overLayOrderMap = new HashMap<>(); EngineerModeOrderParser.parseOrderList(context, file, overLayOrderMap, isEncrypt); //overlay order map for (Map.Entry<String, EngineerModeOrderItem> entry : overLayOrderMap.entrySet()) { if (map.containsKey(entry.getKey())) { if (map.get(entry.getKey()).getOrderItemLevel() != entry.getValue().getOrderItemLevel()) { EngineerModeOrderItem item = entry.getValue(); item.setOrderItemLevel(entry.getValue().getOrderItemLevel()); map.put(entry.getKey(), item); } } } } } orderMapFilter(map, isEncrypt); return version; } private void orderMapFilter(Map<String, EngineerModeOrderItem> orderMap, boolean isEncrypt) { Iterator<Map.Entry<String, EngineerModeOrderItem>> iterator = orderMap.entrySet().iterator(); int level = EngineerModeOrderItem.ORDER_ITEM_LEVEL_DISABLE; while (iterator.hasNext()) { Map.Entry<String, EngineerModeOrderItem> entry = iterator.next(); level = entry.getValue().getOrderItemLevel(); if (level == EngineerModeOrderItem.ORDER_ITEM_LEVEL_DISABLE) { iterator.remove(); continue; } if (ProjectFeatureOptions.IS_CONFIDENTIAL && ( (level & EngineerModeOrderItem.ORDER_ITEM_LEVEL_2) != 0)) { iterator.remove(); continue; } if (isEncrypt && ((level & EngineerModeOrderItem.ORDER_ITEM_LEVEL_1) != 0)) { iterator.remove(); continue; } if (((level & EngineerModeOrderItem.ORDER_ITEM_LEVEL_MASK) == 0) || (level > EngineerModeOrderItem.ORDER_ITEM_LEVEL_MASK)) { Log.i(TAG, "invalid order level = " + level); iterator.remove(); } } } } 打印报错 07-10 20:42:10.374 25370 25370 D AndroidRuntime: RuntimeInit: Starting application from zygote 07-10 20:42:10.375 25370 25370 D AndroidRuntime: Entered RuntimeInit! 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: Unable to go to next stageAttach 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: java.lang.IllegalStateException: Cannot go to Attach from: 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: level = 5 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: stages = [Boot, Attach, Bind, Named, Debugger, Running] 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at android.os.DdmSyncState.next(DdmSyncState.java:108) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at android.os.DdmSyncStageUpdater.next(DdmSyncStageUpdater.java:50) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at android.app.ActivityThread.attach(ActivityThread.java:8465) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at android.app.ActivityThread.systemMain(ActivityThread.java:8549) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at com.oplus.engineermode.command.PayJoyAccessService.shouldRunPayJoyAccessService(PayJoyAccessService.java:47) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at com.oplus.engineermode.command.EngineerModeOrderReceiver.onReceive(EngineerModeOrderReceiver.java:69) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at android.app.ActivityThread.handleReceiver(ActivityThread.java:4792) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2456) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at android.os.Handler.dispatchMessage(Handler.java:107) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at android.os.Looper.loopOnce(Looper.java:232) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at android.os.Looper.loop(Looper.java:317) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at android.app.ActivityThread.main(ActivityThread.java:8791) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at java.lang.reflect.Method.invoke(Native Method) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:585) 07-10 20:42:10.542 25370 25370 W DdmSyncStageUpdater: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:908) 07-10 20:42:10.576 25370 25370 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startActivity:1131 android.content.ContextWrapper.startActivity:438 android.content.ContextWrapper.startActivity:438 com.oplus.engineermode.command.EngineerModeOrderHandler.handleMessage:79 android.os.Handler.dispatchMessage:107 07-10 20:42:10.576 25370 25370 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startActivity:1143 android.app.ContextImpl.startActivity:1132 android.content.ContextWrapper.startActivity:438 android.content.ContextWrapper.startActivity:438 com.oplus.engineermode.command.EngineerModeOrderHandler.handleMessage:79 为什么
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值