UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211962#3816. 元素xiangjyCompile Error//C++2.0kb2024-10-13 09:13:132024-10-13 12:06:52

answer

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
/*
\\\\ \\ \\ \\ \\ \\ \\ \\ || || || || || || // // // // // // // ////
\\\\ \\ \\ \\ \\ \\ \\        _ooOoo_          // // // // // // ////
\\\\ \\ \\ \\ \\ \\          o8888888o            // // // // // ////
\\\\ \\ \\ \\ \\             88" . "88               // // // // ////
\\\\ \\ \\ \\                (| -_- |)                  // // // ////
\\\\ \\ \\                   O\  =  /O                     // // ////
\\\\ \\                   ____/`---'\____                     // ////
\\\\                    .'  \\|     |//  `.                      ////
//==                   /  \\|||  :  |||//  \                     ==\\
//==                  /  _||||| -:- |||||-  \                    ==\\
//==                  |   | \\\  -  /// |   |                    ==\\
//==                  | \_|  ''\---/''  |   |                    ==\\
//==                  \  .-\__  `-`  ___/-. /                    ==\\
//==                ___`. .'  /--.--\  `. . ___                  ==\\
//==             ."" '<  `.___\_<|>_/___.'  >' "".               ==\\
//==            | | :  `- \`.;`\ _ /`;.`/ - ` : | |              \\\\
////            \  \ `-.   \_ __\ /__ _/   .-` /  /              \\\\
////      ========`-.____`-.___\_____/___.-`____.-'========      \\\\
////                           `=---='                           \\\\
//// //   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  \\ \\\\
//// // //      佛祖保佑      永无BUG      永不修改        \\ \\ \\\\
//// // // // // // || || || || || || || || || || \\ \\ \\ \\ \\ \\\\
*/
int a[100010],vis[1000010];
int main(){
	int n,q,l,r;
	scanf("%d%d",&n,&q);
	for(int i=1; i<=n; i++) {
		scanf("%d",&a[i]);
	}
	while(q--) {
		scanf("%d%d",&l,&r);
		for(int i=1; i<=2001; i++) vis[i]=0;
		for(int i=l; i<=r; i++) {
			vis[a[i]]++;
		}
		while(vis[a[r]]>1&&r>l) {
			vis[a[r]]--;
			r--;
		}
		while(l<r&&vis[a[l]]>1) {
			vis[a[l]]--;
			l++;
		}
		printf("%d\n",r-l+1);
	}
	return 0;
}

详细

answer.code: In function 'int main()':
answer.code:32:20: error: 'scanf' was not declared in this scope
  scanf("%d%d",&n,&q);\x0d
                    ^
answer.code:50:22: error: 'printf' was not declared in this scope
   printf("%d\n",r-l+1);\x0d
                      ^