CF:Eugeny and Array

本文深入探讨了AI音视频处理技术及其在AR特效领域的应用,包括视频分割、语义识别、物体检测、识别、语音变声等,以及如何结合OpenGL ES实现美颜直播特效、视频剪辑和3D空间视频处理。同时,文章还涉及了AR技术的实现,如人脸标定、人像分割、人体姿态估计和手势识别。通过实例解析,读者将获得全面的技术理解和实践经验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. Eugeny and Array
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Eugeny has array a = a1, a2, ..., an, consisting of n integers. Each integer ai equals to -1, or to 1. Also, he has m queries:

  • Query number i is given as a pair of integers liri (1 ≤ li ≤ ri ≤ n).
  • The response to the query will be integer 1, if the elements of array a can be rearranged so as the sum ali + ali + 1 + ... + ari = 0, otherwise the response to the query will be integer 0.

Help Eugeny, answer all his queries.

Input

The first line contains integers n and m (1 ≤ n, m ≤ 2·105). The second line contains n integers a1, a2, ..., an (ai = -1, 1). Next mlines contain Eugene's queries. The i-th line contains integers li, ri (1 ≤ li ≤ ri ≤ n).

Output

Print m integers — the responses to Eugene's queries in the order they occur in the input.

Sample test(s)
input
2 3
1 -1
1 1
1 2
2 2
output
0
1
0
input
5 5
-1 1 1 1 -1
1 1
2 3
3 5
2 5
1 5
output
0
1
0
1
0
解题报告:
大概的意思是先给出一个串a(1or-1),然后给出m行l,r两个数,然后重新对a进行排列,如果al+..........+ar=0;输出1否则输出0;
思路,如果r-l+1是奇数,那么数列和肯定不能为0,如果是偶数的话判断一下-1或者1的数量是否够用。
参考代码:
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <cmath>
using namespace std;
int main(){
   // freopen("in.txt","r",stdin);
   int n,m,i,j,l,r,t,n1,m1,count,m_min;
   while(cin>>n>>m)
   {
     l=0;
     r=0;
     n1=0;
     m1=0;
     for(i=0;i<n;i++)
     {
         cin>>t;
         if(t==-1)
        n1++;
        else
        m1++;
     }
     for(i=0;i<m;i++)
     {
         cin>>l>>r;
         count=r-l+1;


       if(count%2!=0)
       {
     cout<<"0"<<endl;
       continue;
       }


       m_min=min(n1,m1);
       if(count/2<=m_min)
       cout<<"1"<<endl;
       else
       cout<<"0"<<endl;
     }


   }
    return 0;
}
Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 6.8.0-60-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro System information as of Wed May 28 02:10:15 UTC 2025 System load: 0.0 Processes: 176 Usage of /: 1.9% of 386.42GB Users logged in: 1 Memory usage: 1% IPv4 address for eth0: 185.199.52.219 Swap usage: 0% IPv6 address for eth0: 2a02:4780:12:27e7::1 Expanded Security Maintenance for Applications is not enabled. 0 updates can be applied immediately. 14 additional security updates can be applied with ESM Apps. Learn more about enabling ESM Apps service at https://ubuntu.com/esm Last login: Wed May 28 02:08:30 2025 from 169.254.0.1 root@srv771551:~# ^C root@srv771551:~# which tabby # 应输出安装路径 tabby --version Command 'tabby' not found, did you mean: command 'ktabby' from deb kgames (2.3-1) Try: apt install <deb name> root@srv771551:~# sudo snap install tabby error: snap "tabby" not found root@srv771551:~# wget https://github.com/Eugeny/tabby/releases/download/v1.0.209/tabby-1.0.209-linux-x64.deb --2025-05-28 02:14:56-- https://github.com/Eugeny/tabby/releases/download/v1.0.209/tabby-1.0.209-linux-x64.deb Resolving github.com (github.com)... 20.207.73.82 Connecting to github.com (github.com)|20.207.73.82|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/77213120/49d65aef-dda0-40ec-8f6c-bb2f59b7b2ef?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250528%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250528T021457Z&X-Amz-Expires=300&X-Amz-Signature=16929604a9e7523d5674ba06f7675fd4c04bf70e8b3d21ddf89c85c14d2a1c45&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtabby-1.0.209-linux-x64.deb&response-content-type=application%2Foctet-stream [following] --2025-05-28 02:14:57-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/77213120/49d65aef-dda0-40ec-8f6c-bb2f59b7b2ef?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250528%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250528T021457Z&X-Amz-Expires=300&X-Amz-Signature=16929604a9e7523d5674ba06f7675fd4c04bf70e8b3d21ddf89c85c14d2a1c45&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtabby-1.0.209-linux-x64.deb&response-content-type=application%2Foctet-stream Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.110.133, 185.199.109.133, ... Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 90647356 (86M) [application/octet-stream] Saving to: 'tabby-1.0.209-linux-x64.deb' tabby-1.0.209-linux-x64.deb 100%[=================================================================================================================================>] 86.45M 6.40MB/s in 13s 2025-05-28 02:15:11 (6.84 MB/s) - 'tabby-1.0.209-linux-x64.deb' saved [90647356/90647356] root@srv771551:~# sudo apt-get install gdebi Reading package lists... Done Building dependency tree... Done Reading state information... Done gdebi is already the newest version (0.9.5.7+nmu7). gdebi set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. root@srv771551:~# sudo gdebi tabby-*.deb /usr/bin/gdebi:113: SyntaxWarning: invalid escape sequence '\S' c = findall("[[(](\S+)/\S+[])]", msg)[0].lower() Reading package lists... Done Building dependency tree... Done Reading state information... Done Reading state information... Done This package is uninstallable Dependency is not satisfiable: gconf2 root@srv771551:~# sudo gdebi tabby-*.deb /usr/bin/gdebi:113: SyntaxWarning: invalid escape sequence '\S' c = findall("[[(](\S+)/\S+[])]", msg)[0].lower() Reading package lists... Done Building dependency tree... Done Reading state information... Done Reading state information... Done This package is uninstallable Dependency is not satisfiable: gconf2 root@srv771551:~# wget https://github.com/Eugeny/tabby/releases/download/v1.0.209/tabby-1.0.209-linux-x64.AppImage --2025-05-28 02:16:02-- https://github.com/Eugeny/tabby/releases/download/v1.0.209/tabby-1.0.209-linux-x64.AppImage Resolving github.com (github.com)... 20.207.73.82 Connecting to github.com (github.com)|20.207.73.82|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/77213120/6838174f-aae8-46a8-875f-4adc31805938?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250528%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250528T021602Z&X-Amz-Expires=300&X-Amz-Signature=366b06d105ad23c750d2b24dfa63c80757d01eaaa1a2827052e5bdca604a9001&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtabby-1.0.209-linux-x64.AppImage&response-content-type=application%2Foctet-stream [following] --2025-05-28 02:16:02-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/77213120/6838174f-aae8-46a8-875f-4adc31805938?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250528%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250528T021602Z&X-Amz-Expires=300&X-Amz-Signature=366b06d105ad23c750d2b24dfa63c80757d01eaaa1a2827052e5bdca604a9001&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtabby-1.0.209-linux-x64.AppImage&response-content-type=application%2Foctet-stream Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.111.133, ... Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.109.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 134111099 (128M) [application/octet-stream] Saving to: 'tabby-1.0.209-linux-x64.AppImage' tabby-1.0.209-linux-x64.AppImage 100%[=================================================================================================================================>] 127.90M 7.66MB/s in 19s 2025-05-28 02:16:22 (6.67 MB/s) - 'tabby-1.0.209-linux-x64.AppImage' saved [134111099/134111099] root@srv771551:~# wget https://github.com/Eugeny/tabby/releases/download/v1.0.209/tabby-1.0.209-linux-x64.AppImage --2025-05-28 02:16:26-- https://github.com/Eugeny/tabby/releases/download/v1.0.209/tabby-1.0.209-linux-x64.AppImage Resolving github.com (github.com)... 20.207.73.82 Connecting to github.com (github.com)|20.207.73.82|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/77213120/6838174f-aae8-46a8-875f-4adc31805938?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250528%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250528T021602Z&X-Amz-Expires=300&X-Amz-Signature=366b06d105ad23c750d2b24dfa63c80757d01eaaa1a2827052e5bdca604a9001&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtabby-1.0.209-linux-x64.AppImage&response-content-type=application%2Foctet-stream [following] --2025-05-28 02:16:26-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/77213120/6838174f-aae8-46a8-875f-4adc31805938?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250528%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250528T021602Z&X-Amz-Expires=300&X-Amz-Signature=366b06d105ad23c750d2b24dfa63c80757d01eaaa1a2827052e5bdca604a9001&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtabby-1.0.209-linux-x64.AppImage&response-content-type=application%2Foctet-stream Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.109.133, ... Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 134111099 (128M) [application/octet-stream] Saving to: 'tabby-1.0.209-linux-x64.AppImage.1' tabby-1.0.209-linux-x64.AppImage.1 100%[=================================================================================================================================>] 127.90M 84.0MB/s in 1.5s 2025-05-28 02:16:29 (84.0 MB/s) - 'tabby-1.0.209-linux-x64.AppImage.1' saved [134111099/134111099] root@srv771551:~# chmod +x *.AppImage root@srv771551:~# which tabby # 应输出安装路径 tabby --version Command 'tabby' not found, did you mean: command 'ktabby' from deb kgames (2.3-1) Try: apt install <deb name> root@srv771551:~# ^C root@srv771551:~# ^C root@srv771551:~# wget https://github.com/Eugeny/tabby/releases/download/v1.0.209/tabby-1.0.209-linux-x64.AppImage --2025-05-28 02:18:08-- https://github.com/Eugeny/tabby/releases/download/v1.0.209/tabby-1.0.209-linux-x64.AppImage Resolving github.com (github.com)... 20.207.73.82 Connecting to github.com (github.com)|20.207.73.82|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/77213120/6838174f-aae8-46a8-875f-4adc31805938?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250528%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250528T021602Z&X-Amz-Expires=300&X-Amz-Signature=366b06d105ad23c750d2b24dfa63c80757d01eaaa1a2827052e5bdca604a9001&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtabby-1.0.209-linux-x64.AppImage&response-content-type=application%2Foctet-stream [following] --2025-05-28 02:18:08-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/77213120/6838174f-aae8-46a8-875f-4adc31805938?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250528%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250528T021602Z&X-Amz-Expires=300&X-Amz-Signature=366b06d105ad23c750d2b24dfa63c80757d01eaaa1a2827052e5bdca604a9001&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtabby-1.0.209-linux-x64.AppImage&response-content-type=application%2Foctet-stream Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.108.133, 185.199.111.133, ... Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 134111099 (128M) [application/octet-stream] Saving to: 'tabby-1.0.209-linux-x64.AppImage.2' tabby-1.0.209-linux-x64.AppImage.2 100%[=================================================================================================================================>] 127.90M 49.2MB/s in 2.6s 2025-05-28 02:18:12 (49.2 MB/s) - 'tabby-1.0.209-linux-x64.AppImage.2' saved [134111099/134111099] root@srv771551:~# sudo apt install libfuse2 # AppImage运行必需的基础依赖[^2] Reading package lists... Done Building dependency tree... Done Reading state information... Done Note, selecting 'libfuse2t64' instead of 'libfuse2' libfuse2t64 is already the newest version (2.9.9-8.1build1). libfuse2t64 set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. root@srv771551:~# chmod +x tabby-*.AppImage root@srv771551:~# ./tabby-*.AppImage [0528/021833.570631:FATAL:electron_main_delegate.cc(294)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180. Trace/breakpoint trap (core dumped) root@srv771551:~# # 将Tabby添加到应用程序菜单 sudo mkdir -p /usr/local/bin sudo mv tabby-*.AppImage /usr/local/bin/tabby root@srv771551:~# sudo apt install fuse3 Reading package lists... Done Building dependency tree... Done Reading state information... Done fuse3 is already the newest version (3.14.0-5build1). fuse3 set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. root@srv771551:~# sha256sum tabby-*.AppImage | grep $(curl -sL 发布页 | grep sha256) sha256sum: 'tabby-*.AppImage': No such file or directory Usage: grep [OPTION]... PATTERNS [FILE]... Try 'grep --help' for more information. root@srv771551:~# ^C root@srv771551:~# ^C root@srv771551:~#
最新发布
05-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值